]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
hash-map-tests.c: fix memory leak
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 8 Jan 2020 18:45:26 +0000 (18:45 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Wed, 8 Jan 2020 18:45:26 +0000 (18:45 +0000)
This commit makes "make selftest-valgrind" clean by fixing this leak:

4 bytes in 1 blocks are definitely lost in loss record 1 of 734
   at 0x483AB1A: calloc (vg_replace_malloc.c:762)
   by 0x261DBE0: xcalloc (xmalloc.c:162)
   by 0x2538C46: selftest::test_map_of_strings_to_int() (hash-map-tests.c:87)
   by 0x253ABD2: selftest::hash_map_tests_c_tests() (hash-map-tests.c:307)
   by 0x24A885B: selftest::run_tests() (selftest-run-tests.c:65)
   by 0x1373D80: toplev::run_self_tests() (toplev.c:2339)
   by 0x1373FA7: toplev::main(int, char**) (toplev.c:2421)
   by 0x2550EFF: main (main.c:39)

gcc/ChangeLog:
* hash-map-tests.c (selftest::test_map_of_strings_to_int): Fix
memory leak.

From-SVN: r280015

gcc/ChangeLog
gcc/hash-map-tests.c

index ce7713f611093a49f72e3e960f8032fa2335ed89..838f564ca90efa313b3e74cd1a37162d51424cae 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-08  David Malcolm  <dmalcolm@redhat.com>
+
+       * hash-map-tests.c (selftest::test_map_of_strings_to_int): Fix
+       memory leak.
+
 2020-01-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/93187
index 4d2ea71be47325c8b97e649a32f2f99958a32da6..743fb26d5717b79aaae42dbdd920a45c04cf7863 100644 (file)
@@ -101,6 +101,8 @@ test_map_of_strings_to_int ()
   ASSERT_EQ (1, string_map.elements ());
   ASSERT_EQ (true, string_map.put (another_ant, 5));
   ASSERT_EQ (1, string_map.elements ());
+
+  free (another_ant);
 }
 
 /* Construct a hash_map using int_hash and verify that