aboutsummaryrefslogtreecommitdiffstats
path: root/ctl-lib
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-07-23 17:32:04 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-07-23 15:38:53 +0000
commitc3d7de27a97f4d4ba7de818d2da3775a85973ee7 (patch)
treee9b2cc801b9410a43c6fe0cf84b6d66a8258af4a /ctl-lib
parenta58d83be3c4dc0ea780ab4094b12dd9d125368bc (diff)
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 <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib')
-rw-r--r--ctl-lib/ctl-lua.c3
1 files changed, 2 insertions, 1 deletions
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;
}