From c3d7de27a97f4d4ba7de818d2da3775a85973ee7 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Mon, 23 Jul 2018 17:32:04 +0200 Subject: Release arguments once C function returned. There was a leack after poping arguments from Lua interpreter. Now when a Lua2C function is called, if there is something to keep from the argument then you should call json_object_get() on it to preserve it. Change-Id: I43e79ed73a507ac2ca7ed4cdc3f16ec009392194 Signed-off-by: Romain Forlot --- ctl-lib/ctl-lua.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ctl-lib/ctl-lua.c') diff --git a/ctl-lib/ctl-lua.c b/ctl-lib/ctl-lua.c index ab0abb6..ac22767 100644 --- a/ctl-lib/ctl-lua.c +++ b/ctl-lib/ctl-lua.c @@ -692,11 +692,12 @@ int Lua2cWrapper(void* luaHandle, char *funcname, Lua2cFunctionT callback) { json_object *argsJ = LuaPopArgs(source, luaState, LUA_FIRST_ARG + 1); int err = (*callback) (source, argsJ, &responseJ); + json_object_put(argsJ); // push error code and eventual response to LUA int count = 1; lua_pushinteger(luaState, err); - if (responseJ)count += LuaPushArgument(source, responseJ); + if (responseJ) count += LuaPushArgument(source, responseJ); return count; } -- cgit 1.2.3-korg