aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/afm-main-plugin/utils-jbus.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2015-12-22 22:04:01 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2015-12-22 22:04:01 +0100
commit84e91aa612523ebedcd1d58d2f2f9c30be4d405b (patch)
tree3387de66dba64dffce2cdeb5f62b630d726ef0f7 /plugins/afm-main-plugin/utils-jbus.c
parent1398adf363c182f25603f7d0c1ff52c5be8267b2 (diff)
afm-main: update adress and bug fix
Change-Id: I01776950ddb1328957a8f59f7316aab1ad223f9a
Diffstat (limited to 'plugins/afm-main-plugin/utils-jbus.c')
-rw-r--r--plugins/afm-main-plugin/utils-jbus.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/afm-main-plugin/utils-jbus.c b/plugins/afm-main-plugin/utils-jbus.c
index 7e65723a..d58def90 100644
--- a/plugins/afm-main-plugin/utils-jbus.c
+++ b/plugins/afm-main-plugin/utils-jbus.c
@@ -272,6 +272,7 @@ static DBusHandlerResult incoming_resp(DBusConnection *connection, DBusMessage *
reply = json_tokener_parse(str);
status = reply ? 0 : -1;
jrw->onresp_j(iserror ? -1 : status, reply, jrw->data);
+ json_object_put(reply);
}
free(jrw);
@@ -318,6 +319,7 @@ static DBusHandlerResult incoming_call(DBusConnection *connection, DBusMessage *
if (query == NULL)
return reply_invalid_request(jreq);
srv->oncall_j(jreq, query);
+ json_object_put(query);
}
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -350,8 +352,10 @@ static DBusHandlerResult incoming_signal(DBusConnection *connection, DBusMessage
else {
/* handling json only */
obj = json_tokener_parse(str);
- if (obj != NULL)
+ if (obj != NULL) {
sig->onsignal_j(obj);
+ json_object_put(obj);
+ }
}
}
return DBUS_HANDLER_RESULT_HANDLED;
@@ -607,11 +611,17 @@ char *jbus_call_ss_sync(struct jbus *jbus, const char *method, const char *query
struct json_object *jbus_call_sj_sync(struct jbus *jbus, const char *method, const char *query)
{
- const char *str = jbus_call_ss_sync(jbus, method, query);
- return str ? json_tokener_parse(str) : NULL;
+ struct json_object *obj;
+ char *str = jbus_call_ss_sync(jbus, method, query);
+ if (str == NULL)
+ obj = NULL;
+ else {
+ obj = json_tokener_parse(str);
+ free(str);
+ }
+ return obj;
}
-
char *jbus_call_js_sync(struct jbus *jbus, const char *method, struct json_object *query)
{
const char *str = json_object_to_json_string(query);