binding: media: fix memory leak with json objects 87/10687/1
authorMatt Ranostay <matt.ranostay@konsulko.com>
Thu, 24 Aug 2017 20:18:52 +0000 (13:18 -0700)
committerMatt Ranostay <matt.ranostay@konsulko.com>
Thu, 24 Aug 2017 20:33:05 +0000 (13:33 -0700)
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 <matt.ranostay@konsulko.com>
binding/mediaplayer-api.c

index e81c98a..813ab97 100644 (file)
@@ -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);