[pulseaudio-discuss] [PATCH 2/8] json-test: Fix Coverity warning

Peter Meerwald-Stadler pmeerw at pmeerw.net
Wed Sep 6 12:23:56 UTC 2017


Cosmetic resource leak in test code

Coverity ID: #1454314

Signed-off-by: Peter Meerwald-Stadler <pmeerw at pmeerw.net>
---
 src/tests/json-test.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/tests/json-test.c b/src/tests/json-test.c
index 3e956db..0894a30 100644
--- a/src/tests/json-test.c
+++ b/src/tests/json-test.c
@@ -248,7 +248,11 @@ START_TEST(bad_test) {
     };
 
     for (i = 0; i < PA_ELEMENTSOF(bad_parse); i++) {
-        fail_unless(pa_json_parse(bad_parse[i]) == NULL);
+        pa_json_object *obj;
+
+        fail_unless((obj = pa_json_parse(bad_parse[i])) == NULL);
+        if (obj)
+            pa_json_object_free(obj);
     }
 }
 END_TEST
-- 
2.7.4



More information about the pulseaudio-discuss mailing list