From 367991143fc5b8cdc4599358189be5a6fa2fb353 Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Mon, 30 Apr 2012 21:56:28 +0400
Subject: [PATCH] Fix a bug in tarantool_free()

When salloc_init() fails, we call tarantool_free(),
which calls fiber_free(), which tries to destroy the fiber registry
hash, which has not been allocated.

Check that the hash has been allocated, before trying to destroy it.
---
 src/fiber.m | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/fiber.m b/src/fiber.m
index 76ea893449..0adcc4cfe5 100644
--- a/src/fiber.m
+++ b/src/fiber.m
@@ -1023,6 +1023,9 @@ fiber_init(void)
 void
 fiber_free(void)
 {
-	fiber_destroy_all();
-	mh_i32ptr_destroy(fibers_registry);
+	/* Only clean up if initialized. */
+	if (fibers_registry) {
+		fiber_destroy_all();
+		mh_i32ptr_destroy(fibers_registry);
+	}
 }
-- 
GitLab