Code

store_lookup_test: Fixed a memory leak.
authorSebastian Harl <sh@tokkee.org>
Mon, 23 Jun 2014 05:15:45 +0000 (07:15 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 23 Jun 2014 05:15:45 +0000 (07:15 +0200)
Thanks to Travis-CI for identifying this! I wonder why my local tests did not
catch this :-(

t/unit/core/store_lookup_test.c

index c125a5913a407c1e177998864d740d1427933d1d..e90dd06c1acee054d6388dcbd0ef7e5b99c4e4d0 100644 (file)
@@ -302,16 +302,26 @@ START_TEST(test_store_cond)
                                golden_data[i].attr, buf);
 
                for (j = 0; j < SDB_STATIC_ARRAY_LEN(tests); ++j) {
-                       sdb_store_matcher_t *m = tests[j].matcher(c);
+                       sdb_store_matcher_t *m;
                        char m_str[1024];
-                       sdb_object_deref(SDB_OBJ(c));
+
+                       m = tests[j].matcher(c);
+                       fail_unless(m != NULL,
+                                       "sdb_store_<cond>_matcher() = NULL; expected: <matcher>");
+
                        status = sdb_store_matcher_matches(m, obj);
                        fail_unless(status == *tests[j].expected,
                                        "sdb_store_matcher_matches(%s) = %d; expected: %d",
                                        sdb_store_matcher_tostring(m, m_str, sizeof(m_str)),
                                        status, *tests[j].expected);
+
+                       sdb_object_deref(SDB_OBJ(m));
                }
+
+               sdb_object_deref(SDB_OBJ(c));
        }
+
+       sdb_object_deref(SDB_OBJ(obj));
 }
 END_TEST