Skip to content
Snippets Groups Projects
Commit 9f6da135 authored by Li Xiaoming's avatar Li Xiaoming
Browse files

Fix potential memory leak


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 returns during the
process.

Bug-AGL: SPEC-3584

Change-Id: Icb1eae050294f4438ad89739e324c5483b6b3441
Signed-off-by: default avatarLi Xiaoming <lixm.fnst@cn.fujitsu.com>
parent b836eb90
No related branches found
No related tags found
No related merge requests found
......@@ -80,7 +80,7 @@ static void navigation_subscribe_unsubscribe(afb_req_t request,
gboolean unsub)
{
struct navigation_state *ns = navigation_get_userdata();
json_object *jresp = json_object_new_object();
json_object *jresp = NULL;
const char *value;
afb_event_t event;
int rc;
......@@ -121,6 +121,7 @@ static void navigation_subscribe_unsubscribe(afb_req_t request,
return;
}
jresp = json_object_new_object();
afb_req_success_f(request, jresp, "Navigation %s to event \"%s\"",
!unsub ? "subscribed" : "unsubscribed",
value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment