summaryrefslogtreecommitdiffstats
path: root/binding/network-api.c
diff options
context:
space:
mode:
authorLi Xiaoming <lixm.fnst@cn.fujitsu.com>2021-01-13 19:42:37 +0800
committerLi Xiaoming <lixm.fnst@cn.fujitsu.com>2021-01-14 02:02:58 +0000
commite863ff24df3332c57030366bb505189a28edf1ea (patch)
tree96c2cbfe8e9db43c630dc408bd04b2f5b471d0d0 /binding/network-api.c
parent8c6e15356eaa9b13ff76873e79362ad78c730ec5 (diff)
It is better to init jresp as NULL, and allocate new memory when it is used, this will avoid the memory leak if the function return during the process. jobj should be freed before function returns. Bug-AGL: SPEC-3584 Change-Id: I4b917f7ecd06a1800d453ec43ffeccee89d923c6 Signed-off-by: Li Xiaoming <lixm.fnst@cn.fujitsu.com>
Diffstat (limited to 'binding/network-api.c')
-rw-r--r--binding/network-api.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/binding/network-api.c b/binding/network-api.c
index 0206973..d48b5ff 100644
--- a/binding/network-api.c
+++ b/binding/network-api.c
@@ -1065,7 +1065,7 @@ static void network_subscribe_unsubscribe(afb_req_t request,
gboolean unsub)
{
struct network_state *ns = network_get_userdata(request);
- json_object *jresp = json_object_new_object();
+ json_object *jresp = NULL;
const char *value;
afb_event_t event;
int rc;
@@ -1096,6 +1096,7 @@ static void network_subscribe_unsubscribe(afb_req_t request,
return;
}
+ jresp = json_object_new_object();
afb_req_success_f(request, jresp, "Network %s to event \"%s\"",
!unsub ? "subscribed" : "unsubscribed",
value);