From 4a245cfd11c387c297bff9b000142a26683b1d1d 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 e81c98a..813ab97 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