From 394823a7345f40543c3b506c657570e9e08f6a3a Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Fri, 7 Jul 2023 17:47:15 +0100 Subject: [PATCH] Valgrind: fix "definitely lost" memory from get_random_string() - test-commodities ==88718== 8 bytes in 1 blocks are definitely lost in loss record 21 of 1,880 ==88718== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==88718== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1) ==88718== by 0x11D6B9: get_random_string_without (test-stuff.c:312) ==88718== by 0x11D736: get_random_string (test-stuff.c:333) ==88718== by 0x116A91: test_commodity() (test-commodities.cpp:60) ==88718== by 0x117355: main (test-commodities.cpp:196) + 5 more --- libgnucash/engine/test/test-commodities.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libgnucash/engine/test/test-commodities.cpp b/libgnucash/engine/test/test-commodities.cpp index 089880f9dc..7ed5871678 100644 --- a/libgnucash/engine/test/test-commodities.cpp +++ b/libgnucash/engine/test/test-commodities.cpp @@ -72,6 +72,7 @@ test_commodity(void) do_test( g_strcmp0(fullname, gnc_commodity_get_fullname(com)) == 0, "fullnames equal test"); + g_free (fullname); do_test( g_strcmp0(name_space, gnc_commodity_get_namespace(com)) == 0, @@ -80,10 +81,12 @@ test_commodity(void) do_test( g_strcmp0(mnemonic, gnc_commodity_get_mnemonic(com)) == 0, "mnemonic equal test"); + g_free (mnemonic); do_test( g_strcmp0(cusip, gnc_commodity_get_cusip(com)) == 0, "cusip equal test"); + g_free (cusip); do_test( gnc_commodity_get_fraction(com) == fraction, @@ -126,6 +129,10 @@ test_commodity(void) com2 = gnc_commodity_new(book, fullname, name_space, mnemonic, cusip, fraction); + g_free (fullname); + g_free (mnemonic); + g_free (cusip); + do_test( gnc_commodity_equiv(com, com2), "commodity equiv");