From 866fc80a1010eb14a30ead1685a2066e04a0c473 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 24 Aug 2017 13:18:52 -0700 Subject: binding: media: fix memory leak with json objects In case of empty media insertion the allocated json_object's weren't used. Run json_object_put to force the freeing of the objects. Bug-AGL: SPEC-842 Change-Id: I48fe8cf0824030119140fa581223c282855981d7 Signed-off-by: Matt Ranostay --- binding/mediaplayer-api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/binding/mediaplayer-api.c b/binding/mediaplayer-api.c index 44944df..f2f3302 100644 --- a/binding/mediaplayer-api.c +++ b/binding/mediaplayer-api.c @@ -86,8 +86,11 @@ static json_object *new_json_object_from_device(GList *list) json_object_array_add(jarray, jstring); } - if (jstring == NULL) + if (jstring == NULL) { + json_object_put(jarray); + json_object_put(jresp); return NULL; + } json_object_object_add(jresp, "Media", jarray); -- cgit 1.2.3-korg