aboutsummaryrefslogtreecommitdiffstats
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-12-13 15:02:55 +0100
commit7fd47c1f35871041ef8959c0591fcd8cd5cff724 (patch)
treee9b2cc801b9410a43c6fe0cf84b6d66a8258af4a
parent97e31a3f1ce9d884ac043e570f54caaa47bf88f5 (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>
-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;
}