Fix memory leaks in json_equal() tests
authorPetri Lehtinen <petri@digip.org>
Sun, 10 Jan 2010 19:01:59 +0000 (21:01 +0200)
committerPetri Lehtinen <petri@digip.org>
Sun, 10 Jan 2010 19:02:08 +0000 (21:02 +0200)
test/suites/api/test_equal.c

index e056750..ab2edcd 100644 (file)
@@ -137,12 +137,12 @@ static void test_equal_object()
     if(json_equal(object1, object2))
         fail("json_equal fails for two inequal objects");
 
-    json_object_set(object2, "c", json_integer(3));
+    json_object_set_new(object2, "c", json_integer(3));
     if(json_equal(object1, object2))
         fail("json_equal fails for two inequal objects");
 
     json_object_del(object2, "c");
-    json_object_set(object2, "d", json_integer(2));
+    json_object_set_new(object2, "d", json_integer(2));
     if(json_equal(object1, object2))
         fail("json_equal fails for two inequal objects");
 
@@ -174,6 +174,9 @@ static void test_equal_complex()
     if(!json_equal(value1, value2))
         fail("json_equal fails for two inequal strings");
 
+    json_decref(value1);
+    json_decref(value2);
+
     /* TODO: There's no negative test case here */
 }