From e2f14e81bd20cc944bdecba7fcea20a4b4eddec0 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 11 Nov 2020 13:55:35 -0800 Subject: [PATCH] [subset] fix memory leaks in test-repacker. --- src/test-repacker.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/test-repacker.cc b/src/test-repacker.cc index 33067b252..1b4860394 100644 --- a/src/test-repacker.cc +++ b/src/test-repacker.cc @@ -211,6 +211,8 @@ static void test_sort_kahn_1 () assert(strncmp (graph.object (0).head, "ghi", 3) == 0); assert(graph.object (0).links.length == 0); + + free (buffer); } static void test_sort_kahn_2 () @@ -243,6 +245,8 @@ static void test_sort_kahn_2 () assert(strncmp (graph.object (0).head, "jkl", 3) == 0); assert(graph.object (0).links.length == 0); + + free (buffer); } static void test_sort_shortest () @@ -255,7 +259,6 @@ static void test_sort_shortest () graph_t graph (c.object_graph ()); graph.sort_shortest_distance (); - assert(strncmp (graph.object (4).head, "abc", 3) == 0); assert(graph.object (4).links.length == 3); assert(graph.object (4).links[0].objidx == 2); @@ -275,6 +278,8 @@ static void test_sort_shortest () assert(strncmp (graph.object (0).head, "jkl", 3) == 0); assert(graph.object (0).links.length == 0); + + free (buffer); } static void test_duplicate_leaf () @@ -309,6 +314,8 @@ static void test_duplicate_leaf () assert(strncmp (graph.object (0).head, "mn", 2) == 0); assert(graph.object (0).links.length == 0); + + free (buffer); } static void test_duplicate_interior () @@ -348,6 +355,8 @@ static void test_duplicate_interior () assert(strncmp (graph.object (0).head, "opqrst", 6) == 0); assert(graph.object (0).links.length == 0); + + free (buffer); } static void @@ -368,6 +377,8 @@ test_serialize () assert (actual == expected); + actual.free (); + expected.free (); free (buffer_1); free (buffer_2); } @@ -381,6 +392,8 @@ static void test_will_overflow_1 () graph_t graph (c.object_graph ()); assert (!graph.will_overflow (nullptr)); + + free (buffer); } static void test_will_overflow_2 () @@ -392,6 +405,8 @@ static void test_will_overflow_2 () graph_t graph (c.object_graph ()); assert (graph.will_overflow (nullptr)); + + free (buffer); } static void test_will_overflow_3 () @@ -403,6 +418,8 @@ static void test_will_overflow_3 () graph_t graph (c.object_graph ()); assert (graph.will_overflow (nullptr)); + + free (buffer); } static void test_resolve_overflows_via_sort ()