aboutsummaryrefslogtreecommitdiffstats
path: root/ctl-lib
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-05-07 14:59:43 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-05-11 11:33:25 +0200
commitc5250690f38e4995a9b32d81e406894f92584a38 (patch)
treeff3c8d806b701aec56b3e6419c3249677c3a4db2 /ctl-lib
parent641001d1d02790dbadea7db9e7d9e1638fe8c9ef (diff)
Improve json object release
For convenience queryJ will always be released. Users has to call json_object_get to be able to use it after that. API subcall use an intermediate variable to avoid modifying this parameter in case of user wanna use it after that. Change-Id: I98f478d3fc0c4ef28234811333b9effd8289e74d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib')
-rw-r--r--ctl-lib/ctl-action.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/ctl-lib/ctl-action.c b/ctl-lib/ctl-action.c
index acad15d..8459449 100644
--- a/ctl-lib/ctl-action.c
+++ b/ctl-lib/ctl-action.c
@@ -63,6 +63,7 @@ PUBLIC void ActionExecOne(CtlSourceT *source, CtlActionT* action, json_object *q
if(queryJ) {
json_object_object_foreach(queryJ, key, val) {
+ json_object_get(val);
json_object_object_add(subcallArgsJ, key, val);
}
}
@@ -97,7 +98,6 @@ PUBLIC void ActionExecOne(CtlSourceT *source, CtlActionT* action, json_object *q
if (err) {
AFB_ApiError(action->api, "ActionExecOne(Lua) uid=%s func=%s args=%s", source->uid, action->exec.lua.funcname, json_object_get_string(action->argsJ));
}
- json_object_put(queryJ);
break;
#endif
@@ -106,16 +106,15 @@ PUBLIC void ActionExecOne(CtlSourceT *source, CtlActionT* action, json_object *q
if (err) {
AFB_ApiError(action->api, "ActionExecOne(Callback) uid%s plugin=%s function=%s args=%s", source->uid, action->exec.cb.plugin->uid, action->exec.cb.funcname, json_object_get_string(action->argsJ));
}
- json_object_put(queryJ);
break;
default:
{
AFB_ApiError(action->api, "ActionExecOne(unknown) API type uid=%s", source->uid);
- json_object_put(queryJ);
break;
}
}
+ json_object_put(queryJ);
}