From 9619985589a63f78a5eaa36b8ad8542d1a0e5c34 Mon Sep 17 00:00:00 2001
From: Mergen Imeev <imeevma@gmail.com>
Date: Wed, 30 Oct 2019 13:39:14 +0300
Subject: [PATCH] netbox: fix memory leak in connect()

This patch fixes memory leak in lbox_tuple_format_new().

Closes #4588
---
 src/box/lua/misc.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/box/lua/misc.cc b/src/box/lua/misc.cc
index 7b8b9dcade..79b6cfe3a4 100644
--- a/src/box/lua/misc.cc
+++ b/src/box/lua/misc.cc
@@ -231,6 +231,12 @@ lbox_tuple_format_new(struct lua_State *L)
 	struct tuple_format *format =
 		tuple_format_new(&tuple_format_runtime->vtab, NULL, NULL, 0,
 				 NULL, 0, 0, dict, false, false);
+	/*
+	 * Since dictionary reference counter is 1 from the
+	 * beginning and after creation of the tuple_format
+	 * increases by one, we must decrease it once.
+	 */
+	tuple_dictionary_unref(dict);
 	if (format == NULL)
 		return luaT_error(L);
 	return lbox_push_tuple_format(L, format);
-- 
GitLab