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
This commit is contained in:
Richard Cohen
2023-07-07 17:47:15 +01:00
parent 47f76fcf03
commit 394823a734

View File

@@ -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");