Valgrind: fix "definitely lost" memory from get_random_string() - test-customer

==88327== 8 bytes in 1 blocks are definitely lost in loss record 13 of 667
==88327==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==88327==    by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
==88327==    by 0x10B890: get_random_string_without (test-stuff.c:312)
==88327==    by 0x10B90D: get_random_string (test-stuff.c:333)
==88327==    by 0x10AC7A: test_string_fcn (test-customer.c:146)
==88327==    by 0x10A82E: test_customer (test-customer.c:79)
==88327==    by 0x10B012: main (test-customer.c:229)

+ 3 more
This commit is contained in:
Richard Cohen
2023-07-07 15:03:38 +01:00
parent 394823a734
commit 2f0c045187

View File

@@ -111,16 +111,16 @@ test_customer (void)
g_list_free (list);
}
{
const char *str = get_random_string();
const char *res;
char *str = get_random_string();
res = NULL;
gncCustomerBeginEdit(customer);
gncCustomerSetName (customer, str);
gncCustomerCommitEdit(customer);
res = qof_object_printable (GNC_ID_CUSTOMER, customer);
const char *res = qof_object_printable (GNC_ID_CUSTOMER, customer);
do_test (res != NULL, "Printable NULL?");
do_test (g_strcmp0 (str, res) == 0, "Printable equals");
g_free (str);
}
do_test (gncCustomerGetJoblist (customer, TRUE) == NULL, "joblist empty");
@@ -143,7 +143,7 @@ test_string_fcn (QofBook *book, const char *message,
const char * (*get)(const GncCustomer *))
{
GncCustomer *customer = gncCustomerCreate (book);
char const *str = get_random_string ();
char *str = get_random_string ();
do_test (!gncCustomerIsDirty (customer), "test if start dirty");
gncCustomerBeginEdit (customer);
@@ -158,6 +158,7 @@ test_string_fcn (QofBook *book, const char *message,
*/
// do_test (!gncCustomerIsDirty (customer), "test dirty after commit");
do_test (g_strcmp0 (get (customer), str) == 0, message);
g_free (str);
gncCustomerSetActive (customer, FALSE);
count++;
}