From f52bb3484e1000001569a86184e5ece1835c8af6 Mon Sep 17 00:00:00 2001 From: Li Xiaoming Date: Thu, 18 Feb 2021 14:57:13 +0800 Subject: Fix potential memory leak json structure allocating code should be placed in where it is used, if there is a condition check which may cause a return before the before-mentioned place in the function. Bug-AGL: SPEC-3584 Change-Id: I06318f408477df441074b38c4d1e33534820db52 Signed-off-by: Li Xiaoming --- binding/afm-geoclue-binding.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/binding/afm-geoclue-binding.c b/binding/afm-geoclue-binding.c index 07b19e1..7aef809 100644 --- a/binding/afm-geoclue-binding.c +++ b/binding/afm-geoclue-binding.c @@ -101,14 +101,13 @@ static void send_event(GClueSimple *simple) static void get_data(afb_req_t request) { - json_object *jresp = json_object_new_object(); - GClueLocation *location; - if (simple == NULL) { afb_req_fail(request, "failed", "No GeoClue instance available"); return; } + json_object *jresp = json_object_new_object(); + GClueLocation *location; location = gclue_simple_get_location(simple); populate_json(jresp, location); -- cgit 1.2.3-korg