aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-04-25 16:46:46 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-04-25 16:49:39 +0200
commit4644264333b29d58bc50085a9d97c74770b8b86a (patch)
treea239d1c6bc13b8dd5b49fc086f351cb9516cc10f /plugins
parentdacc6291685258ca2a77ef17a0bf414bce917c20 (diff)
avoid double free
Change-Id: Ibe92117ab104aca7ae923378198b36b0a273ec47 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/afm-main-plugin/afm-main-plugin.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins/afm-main-plugin/afm-main-plugin.c b/plugins/afm-main-plugin/afm-main-plugin.c
index d7ef198d..553cffc3 100644
--- a/plugins/afm-main-plugin/afm-main-plugin.c
+++ b/plugins/afm-main-plugin/afm-main-plugin.c
@@ -26,6 +26,7 @@
#include "utils-sbus.h"
#include "utils-jbus.h"
+static const char _added_[] = "added";
static const char _auto_[] = "auto";
static const char _continue_[] = "continue";
static const char _changed_[] = "changed";
@@ -87,6 +88,7 @@ static void embed_call_void(struct afb_req request, const char *method)
afb_req_fail(request, "failed", "framework daemon failure");
return;
}
+ obj = json_object_get(obj);
obj = embed(method, obj);
if (obj == NULL) {
afb_req_fail(request, "failed", "framework daemon failure");
@@ -117,6 +119,7 @@ static void call_appid(struct afb_req request, const char *method)
afb_req_fail(request, "failed", "framework daemon failure");
return;
}
+ obj = json_object_get(obj);
afb_req_success(request, obj, NULL);
}
@@ -136,6 +139,7 @@ static void call_runid(struct afb_req request, const char *method)
afb_req_fail(request, "failed", "framework daemon failure");
return;
}
+ obj = json_object_get(obj);
afb_req_success(request, obj, NULL);
}
@@ -186,6 +190,7 @@ static void start(struct afb_req request)
free(query);
/* check status */
+ obj = json_object_get(obj);
if (obj == NULL) {
afb_req_fail(request, "failed", "framework daemon failure");
return;
@@ -224,7 +229,7 @@ static void state(struct afb_req request)
static void install(struct afb_req request)
{
- struct json_object *obj;
+ struct json_object *obj, *added;
char *query;
const char *filename;
struct afb_arg arg;
@@ -245,6 +250,7 @@ static void install(struct afb_req request)
obj = jbus_call_sj_sync(jbus, _install_, query);
if (interface->verbosity)
+;
fprintf(stderr, "(afm-main-plugin) install(%s) -> %s\n", query,
obj ? json_object_to_json_string(obj) : "NULL");
free(query);
@@ -256,6 +262,9 @@ static void install(struct afb_req request)
}
/* embed if needed */
+ if (json_object_object_get_ex(obj, _added_, &added))
+ obj = added;
+ obj = json_object_get(obj);
obj = embed(_id_, obj);
afb_req_success(request, obj, NULL);
}