gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Thu Jun 22 16:25:31 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/4c67cc09 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/518dab24 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fa0824e9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2168c6f3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a5513b45 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a1893ef5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/46e6477f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f1a3f2a8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2e861ab6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e5a26e3c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4018ff17 (commit)
	from  https://github.com/Gnucash/gnucash/commit/b041a766 (commit)



commit 4c67cc09a694639550389d7ec2606dfa47e66fcb
Merge: b041a76690 518dab2429
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Jun 22 13:24:56 2023 -0700

    Merge Richard Cohen's 'valgrind-test-fixes' into stable.


commit 518dab24296bec3340512908845f9d0be186aa11
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Fri Jun 9 14:15:48 2023 +0100

    Valgrind: fix "Conditional jump depends on uninitialised value" - test-split-register-copy-ops
    
    - Don't save the address of a stack variable
    
    ==105765== Conditional jump or move depends on uninitialised value(s)
    ==105765==    at 0x10E763: test_gnc_float_txn_to_txn_swap_accounts (utest-split-register-copy-ops.c:540)
    ==105765==    by 0x5109675: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x510938A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x510938A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x510938A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x5109BC9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x5103FFC: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x10BC6F: main (test-split-register.c:45)
    ==105765==
    ==105765== Conditional jump or move depends on uninitialised value(s)
    ==105765==    at 0x4877C57: gnc_float_txn_to_txn_swap_accounts (split-register-copy-ops.c:433)
    ==105765==    by 0x10E7E1: test_gnc_float_txn_to_txn_swap_accounts (utest-split-register-copy-ops.c:548)
    ==105765==    by 0x5109675: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x510938A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x510938A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x510938A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x5109BC9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x5103FFC: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x10BC6F: main (test-split-register.c:45)
    ==105765==
    ==105765== Conditional jump or move depends on uninitialised value(s)
    ==105765==    at 0x10EFC1: test_gnc_float_txn_to_txn_swap_accounts (utest-split-register-copy-ops.c:589)
    ==105765==    by 0x5109675: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x510938A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x510938A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x510938A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x5109BC9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x5103FFC: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==105765==    by 0x10BC6F: main (test-split-register.c:45)

diff --git a/gnucash/register/ledger-core/test/utest-split-register-copy-ops.c b/gnucash/register/ledger-core/test/utest-split-register-copy-ops.c
index 69e946ae63..09c9474514 100644
--- a/gnucash/register/ledger-core/test/utest-split-register-copy-ops.c
+++ b/gnucash/register/ledger-core/test/utest-split-register-copy-ops.c
@@ -528,9 +528,8 @@ test_gnc_float_txn_get_other_float_split (FlFixture *fixture, gconstpointer pDat
 void gnc_float_txn_to_txn_swap_accounts (const FloatingTxn *ft, Transaction *txn, Account *acct1, Account *acct2, gboolean do_commit)// C: 1  Local: 1:0:0
 */
 static void
-test_gnc_float_txn_to_txn_swap_accounts (FlFixture *fixture, gconstpointer pData)
+impl_test_gnc_float_txn_to_txn_swap_accounts (FlFixture *fixture,  const SwapCommitPrefs *prefs)
 {
-    SwapCommitPrefs *prefs = (SwapCommitPrefs*)pData;
     Transaction *txn = xaccMallocTransaction (fixture->book);
     Account *sw_acct1 = NULL, *sw_acct2 = NULL;
     Account *exp_acct1 = fixture->acc1, *exp_acct2 = fixture->acc2;
@@ -591,11 +590,37 @@ test_gnc_float_txn_to_txn_swap_accounts (FlFixture *fixture, gconstpointer pData
     xaccTransDestroy (txn);
 }
 
+static void
+test_gnc_float_txn_to_txn_swap_accounts_noswap_nocommit (FlFixture *fixture, gconstpointer pData)
+{
+    SwapCommitPrefs prefs = {FALSE, FALSE};
+    impl_test_gnc_float_txn_to_txn_swap_accounts(fixture, &prefs);
+}
+
+static void
+test_gnc_float_txn_to_txn_swap_accounts_noswap_commit (FlFixture *fixture, gconstpointer pData)
+{
+    SwapCommitPrefs prefs = {FALSE, TRUE};
+    impl_test_gnc_float_txn_to_txn_swap_accounts(fixture, &prefs);
+}
+
+static void
+test_gnc_float_txn_to_txn_swap_accounts_swap_commit (FlFixture *fixture, gconstpointer pData)
+{
+    SwapCommitPrefs prefs = {TRUE, TRUE};
+    impl_test_gnc_float_txn_to_txn_swap_accounts(fixture, &prefs);
+}
+
+static void
+test_gnc_float_txn_to_txn_swap_accounts_swap_nocommit (FlFixture *fixture, gconstpointer pData)
+{
+    SwapCommitPrefs prefs = {TRUE, FALSE};
+    impl_test_gnc_float_txn_to_txn_swap_accounts(fixture, &prefs);
+}
 
 void
 test_suite_split_register_copy_ops (void)
 {
-    SwapCommitPrefs prefs;
     GNC_TEST_ADD (suitename, "gnc split to float split", Fixture, NULL, setup, test_gnc_split_to_float_split, teardown);
     GNC_TEST_ADD (suitename, "gnc float split to split", Fixture, NULL, setup, test_gnc_float_split_to_split, teardown);
     GNC_TEST_ADD (suitename, "gnc float txn to float txn", Fixture, NULL, setup, test_gnc_txn_to_float_txn, teardown);
@@ -603,14 +628,9 @@ test_suite_split_register_copy_ops (void)
     GNC_TEST_ADD (suitename, "gnc float txn get float split", FlFixture, NULL, flsetup, test_gnc_float_txn_get_float_split, flteardown);
     GNC_TEST_ADD (suitename, "gnc float txn get other float split", FlFixture, NULL, flsetup, test_gnc_float_txn_get_other_float_split, flteardown);
 
-    prefs.swap_accts = FALSE;
-    prefs.docommit = FALSE;
-    GNC_TEST_ADD (suitename, "gnc float txn to txn noswap nocommit", FlFixture, &prefs, flsetup, test_gnc_float_txn_to_txn_swap_accounts, flteardown);
-    prefs.docommit = TRUE;
-    GNC_TEST_ADD (suitename, "gnc float txn to txn noswap commit", FlFixture, &prefs, flsetup, test_gnc_float_txn_to_txn_swap_accounts, flteardown);
-    prefs.swap_accts = TRUE;
-    GNC_TEST_ADD (suitename, "gnc float txn to txn swap commit", FlFixture, &prefs, flsetup, test_gnc_float_txn_to_txn_swap_accounts, flteardown);
-    prefs.docommit = FALSE;
-    GNC_TEST_ADD (suitename, "gnc float txn to txn swap nocommit", FlFixture, &prefs, flsetup, test_gnc_float_txn_to_txn_swap_accounts, flteardown);
+    GNC_TEST_ADD (suitename, "gnc float txn to txn noswap nocommit", FlFixture, NULL, flsetup, test_gnc_float_txn_to_txn_swap_accounts_noswap_nocommit, flteardown);
+    GNC_TEST_ADD (suitename, "gnc float txn to txn noswap commit", FlFixture, NULL, flsetup, test_gnc_float_txn_to_txn_swap_accounts_noswap_commit, flteardown);
+    GNC_TEST_ADD (suitename, "gnc float txn to txn swap commit", FlFixture, NULL, flsetup, test_gnc_float_txn_to_txn_swap_accounts_swap_commit, flteardown);
+    GNC_TEST_ADD (suitename, "gnc float txn to txn swap nocommit", FlFixture, NULL, flsetup, test_gnc_float_txn_to_txn_swap_accounts_swap_nocommit, flteardown);
 
 }

commit fa0824e9038074ef7e7004203caea66d926f4cd2
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Sat Jun 17 14:03:04 2023 +0100

    Valgrind: fix "Invalid read" - test-vendor
    
    ==4031== Invalid read of size 8
    ==4031==    at 0x4E58C09: gncVendorGetAddr (gncVendor.c:677)
    ==4031==    by 0x10A7E3: test_vendor (test-vendor.c:97)
    ...
    ==4031==  Address 0x7e0c4e8 is 168 bytes inside a block of size 232 free'd
    ==4031==    at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==4031==    by 0x51526C3: g_type_free_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4031==    by 0x4E58616: gncVendorFree (gncVendor.c:511)
    ==4031==    by 0x4E58EFF: vendor_free (gncVendor.c:782)
    ==4031==    by 0x4E8611E: qof_commit_edit_part2 (qofinstance.cpp:1034)
    ==4031==    by 0x4E58F59: gncVendorCommitEdit (gncVendor.c:788)
    ==4031==    by 0x4E584EF: gncVendorDestroy (gncVendor.c:483)
    ==4031==    by 0x10A729: test_vendor (test-vendor.c:80)
    ...
    ==4031==  Block was alloc'd at
    ==4031==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==4031==    by 0x5033550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==4031==    by 0x5157CBC: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4031==    by 0x513F20F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4031==    by 0x51407B7: g_object_new_with_properties (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4031==    by 0x5141560: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4031==    by 0x4E583CF: gncVendorCreate (gncVendor.c:459)
    ==4031==    by 0x10A6A5: test_vendor (test-vendor.c:74)
    ...

diff --git a/libgnucash/engine/test/test-vendor.c b/libgnucash/engine/test/test-vendor.c
index 3f030e5c8e..8e3e19cfd7 100644
--- a/libgnucash/engine/test/test-vendor.c
+++ b/libgnucash/engine/test/test-vendor.c
@@ -94,11 +94,12 @@ test_vendor (void)
         //test_bool_fcn (book, "TaxIncluded", gncVendorSetTaxIncluded, gncVendorGetTaxIncluded);
         test_bool_fcn (book, "Active", gncVendorSetActive, gncVendorGetActive);
 
-        do_test (gncVendorGetAddr (vendor) != NULL, "Addr");
-
         guid_replace (&guid);
         vendor = gncVendorCreate (book);
         count++;
+
+        do_test (gncVendorGetAddr (vendor) != NULL, "Addr");
+
         gncVendorSetGUID (vendor, &guid);
         do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(vendor))), "guid compare");
     }

commit 2168c6f301338746d890c363ddb84e4821571c86
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Sat Jun 17 14:02:48 2023 +0100

    Valgrind: fix "Invalid read" - test-employee
    
    ==4029== Invalid read of size 8
    ==4029==    at 0x4E41F15: gncEmployeeGetAddr (gncEmployee.c:642)
    ==4029==    by 0x10A8A5: test_employee (test-employee.c:97)
    ...
    ==4029==  Address 0x7e0c208 is 152 bytes inside a block of size 248 free'd
    ==4029==    at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==4029==    by 0x51526C3: g_type_free_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4029==    by 0x4E418D5: gncEmployeeFree (gncEmployee.c:477)
    ==4029==    by 0x4E42144: emp_free (gncEmployee.c:714)
    ==4029==    by 0x4E8611E: qof_commit_edit_part2 (qofinstance.cpp:1034)
    ==4029==    by 0x4E4219E: gncEmployeeCommitEdit (gncEmployee.c:721)
    ==4029==    by 0x4E41823: gncEmployeeDestroy (gncEmployee.c:459)
    ==4029==    by 0x10A77F: test_employee (test-employee.c:79)
    ...
    ==4029==  Block was alloc'd at
    ==4029==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==4029==    by 0x5033550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==4029==    by 0x5157CBC: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4029==    by 0x513F20F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4029==    by 0x51407B7: g_object_new_with_properties (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4029==    by 0x5141560: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4029==    by 0x4E416DA: gncEmployeeCreate (gncEmployee.c:434)
    ==4029==    by 0x10A6FB: test_employee (test-employee.c:73)
    ...

diff --git a/libgnucash/engine/test/test-employee.c b/libgnucash/engine/test/test-employee.c
index e7f476da3e..1010febf36 100644
--- a/libgnucash/engine/test/test-employee.c
+++ b/libgnucash/engine/test/test-employee.c
@@ -94,11 +94,12 @@ test_employee (void)
 
         test_bool_fcn (book, "Active", gncEmployeeSetActive, gncEmployeeGetActive);
 
-        do_test (gncEmployeeGetAddr (employee) != NULL, "Addr");
-
         guid_replace (&guid);
         employee = gncEmployeeCreate (book);
         count++;
+
+        do_test (gncEmployeeGetAddr (employee) != NULL, "Addr");
+
         gncEmployeeSetGUID (employee, &guid);
         do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(employee))), "guid compare");
     }

commit a5513b45d540b14a5a61198c7f6bdee41e8c2372
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Thu Jun 8 16:46:53 2023 +0100

    Valgrind: fix "Invalid read" - test-customer
    
    ==4028== Invalid read of size 8
    ==4028==    at 0x4E3F641: gncCustomerGetAddr (gncCustomer.c:579)
    ==4028==    by 0x10A8EE: test_customer (test-customer.c:90)
    ...
    ==4028==  Address 0x7e861b8 is 168 bytes inside a block of size 272 free'd
    ==4028==    at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==4028==    by 0x51526C3: g_type_free_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x4E3EDD6: gncCustomerFree (gncCustomer.c:368)
    ==4028==    by 0x4E3F57B: cust_free (gncCustomer.c:551)
    ==4028==    by 0x4E8611E: qof_commit_edit_part2 (qofinstance.cpp:1034)
    ==4028==    by 0x4E3F5D5: gncCustomerCommitEdit (gncCustomer.c:557)
    ==4028==    by 0x4E3EC89: gncCustomerDestroy (gncCustomer.c:338)
    ==4028==    by 0x10A7EC: test_customer (test-customer.c:71)
    ...
    ==4028==  Block was alloc'd at
    ==4028==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==4028==    by 0x5033550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==4028==    by 0x5157CBC: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x513F20F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x51407B7: g_object_new_with_properties (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x5141560: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x4E3EB0D: gncCustomerCreate (gncCustomer.c:309)
    ==4028==    by 0x10A768: test_customer (test-customer.c:66)
    ...
    
    ==4028== Invalid read of size 8
    ==4028==    at 0x4E3F796: gncCustomerGetShipAddr (gncCustomer.c:633)
    ==4028==    by 0x10A91D: test_customer (test-customer.c:91)
    ...
    ==4028==  Address 0x7e86210 is 256 bytes inside a block of size 272 free'd
    ==4028==    at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==4028==    by 0x51526C3: g_type_free_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x4E3EDD6: gncCustomerFree (gncCustomer.c:368)
    ==4028==    by 0x4E3F57B: cust_free (gncCustomer.c:551)
    ==4028==    by 0x4E8611E: qof_commit_edit_part2 (qofinstance.cpp:1034)
    ==4028==    by 0x4E3F5D5: gncCustomerCommitEdit (gncCustomer.c:557)
    ==4028==    by 0x4E3EC89: gncCustomerDestroy (gncCustomer.c:338)
    ==4028==    by 0x10A7EC: test_customer (test-customer.c:71)
    ...
    ==4028==  Block was alloc'd at
    ==4028==    at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==4028==    by 0x5033550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==4028==    by 0x5157CBC: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x513F20F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x51407B7: g_object_new_with_properties (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x5141560: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.7600.1)
    ==4028==    by 0x4E3EB0D: gncCustomerCreate (gncCustomer.c:309)
    ==4028==    by 0x10A768: test_customer (test-customer.c:66)
    ...

diff --git a/libgnucash/engine/test/test-customer.c b/libgnucash/engine/test/test-customer.c
index 7856798ef9..fc3cc52eca 100644
--- a/libgnucash/engine/test/test-customer.c
+++ b/libgnucash/engine/test/test-customer.c
@@ -87,12 +87,13 @@ test_customer (void)
 
         test_bool_fcn (book, "Active", gncCustomerSetActive, gncCustomerGetActive);
 
-        do_test (gncCustomerGetAddr (customer) != NULL, "Addr");
-        do_test (gncCustomerGetShipAddr (customer) != NULL, "ShipAddr");
-
         guid_replace (&guid);
         customer = gncCustomerCreate (book);
         count++;
+
+        do_test (gncCustomerGetAddr (customer) != NULL, "Addr");
+        do_test (gncCustomerGetShipAddr (customer) != NULL, "ShipAddr");
+
         gncCustomerSetGUID (customer, &guid);
         do_test (guid_equal (&guid, gncCustomerGetGUID (customer)), "guid compare");
     }

commit a1893ef51b867943f050e35fdc3f62ce1fb01fe5
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Sat Jun 17 17:17:21 2023 +0100

    Valgrind: fix "Invalid read" - test-kvp-value
    
    ==7520== Invalid read of size 8
    ==7520==    at 0x4E36DCC: guid_copy (guid.cpp:123)
    ==7520==    by 0x1E3E62: KvpValueImpl::duplicate(KvpValueImpl const&) (kvp-value.cpp:378)
    ==7520==    by 0x1E31CC: KvpValueImpl::KvpValueImpl(KvpValueImpl const&) (kvp-value.cpp:36)
    ==7520==    by 0x1FF6C3: KvpValueTest_Copy_Test::TestBody() (test-kvp-value.cpp:74)
    ...
    ==7520==  Address 0x7e10f48 is 8 bytes inside a block of size 16 free'd
    ==7520==    at 0x4846AFF: operator delete(void*, unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==7520==    by 0x4E36D98: guid_free (guid.cpp:115)
    ==7520==    by 0x1E3D04: void delete_visitor::operator()<_gncGuid*>(_gncGuid*&) (kvp-value.cpp:358)
    ...
    ==7520==  Block was alloc'd at
    ==7520==    at 0x4843FA3: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==7520==    by 0x4E36D5C: guid_malloc (guid.cpp:105)
    ==7520==    by 0x4E36DC3: guid_copy (guid.cpp:122)
    ==7520==    by 0x4E36EB0: guid_new (guid.cpp:153)
    ==7520==    by 0x1FF4DB: KvpValueTest_Copy_Test::TestBody() (test-kvp-value.cpp:68)

diff --git a/libgnucash/engine/test/test-kvp-value.cpp b/libgnucash/engine/test/test-kvp-value.cpp
index 7cf67b0c6b..8f719d7a7a 100644
--- a/libgnucash/engine/test/test-kvp-value.cpp
+++ b/libgnucash/engine/test/test-kvp-value.cpp
@@ -70,6 +70,7 @@ TEST (KvpValueTest, Copy)
     v2 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {*v1}};
     EXPECT_EQ (compare (*v1, *v2), 0);
 
+    guid = guid_new ();
     v1 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {guid}};
     v2 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {*v1}};
     /*This should delete the guid*/

commit 46e6477f889119b2d1e8891bdba5e95c87dd0534
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Wed Jun 21 10:35:22 2023 +0100

    Refactor: use common code to free the list of guids

diff --git a/libgnucash/engine/test-core/test-engine-stuff.cpp b/libgnucash/engine/test-core/test-engine-stuff.cpp
index cc43a2f3ef..076b4aba0e 100644
--- a/libgnucash/engine/test-core/test-engine-stuff.cpp
+++ b/libgnucash/engine/test-core/test-engine-stuff.cpp
@@ -1497,14 +1497,9 @@ get_random_guids(int max)
 }
 
 static void
-free_random_guids(GList *guids)
+free_guids(GList *guids)
 {
-    GList *node;
-
-    for (node = guids; node; node = node->next)
-        guid_free (static_cast<GncGUID*>(node->data));
-
-    g_list_free (guids);
+    g_list_free_full (guids, (GDestroyNotify)guid_free);
 }
 
 static QofQueryOp
@@ -1671,7 +1666,7 @@ get_random_query(void)
              guids,
              compare_param<QofGuidMatch>(QOF_GUID_MATCH_NONE),
              get_random_queryop ());
-            free_random_guids (guids);
+            free_guids (guids);
             break;
 
         case 2: /*PR_ACTION */
@@ -2026,9 +2021,7 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
         }
         xaccQueryAddAccountGUIDMatch (q, list, QOF_GUID_MATCH_ANY, QOF_QUERY_AND);
 
-        for (node = list; node; node = node->next)
-            guid_free (static_cast<GncGUID*>(node->data));
-        g_list_free (list);
+        free_guids (list);
     }
 
     if (query_types & GUID_QT)

commit f1a3f2a8c819a8a23553d916c3da87672c72d6f1
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Mon Jun 19 12:32:22 2023 +0100

    Valgrind: fix "Mismatched free/delete" - test-scm-query etc.
    
    - test-scm-query
    - test-print-queries
    - test-scm-query-string
    
    ==14597== Mismatched free() / delete / delete []
    ==14597==    at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==14597==    by 0x118851: free_random_guids(_GList*) (test-engine-stuff.cpp:1505)
    ==14597==    by 0x118CF5: get_random_query (test-engine-stuff.cpp:1674)
    ...
    ==14597==  Address 0xa1366a0 is 0 bytes inside a block of size 16 alloc'd
    ==14597==    at 0x4843FA3: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==14597==    by 0x5342FA6: guid_malloc (guid.cpp:106)
    ==14597==    by 0x534300D: guid_copy (guid.cpp:123)
    ==14597==    by 0x534311F: guid_new (guid.cpp:154)
    ==14597==    by 0x115D1A: get_random_guid (test-engine-stuff.cpp:207)
    ==14597==    by 0x1187FA: get_random_guids(int) (test-engine-stuff.cpp:1494)
    ==14597==    by 0x118CC0: get_random_query (test-engine-stuff.cpp:1668)
    ...
    
    ==15045== Mismatched free() / delete / delete []
    ==15045==    at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==15045==    by 0x118E96: get_random_query (test-engine-stuff.cpp:1735)
    ...
    ==15045==  Address 0xa077d40 is 0 bytes inside a block of size 16 alloc'd
    ==15045==    at 0x4843FA3: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==15045==    by 0x5342FA6: guid_malloc (guid.cpp:106)
    ==15045==    by 0x534300D: guid_copy (guid.cpp:123)
    ==15045==    by 0x534311F: guid_new (guid.cpp:154)
    ==15045==    by 0x115D1A: get_random_guid (test-engine-stuff.cpp:207)
    ==15045==    by 0x118E65: get_random_query (test-engine-stuff.cpp:1730)
    ...

diff --git a/libgnucash/engine/test-core/test-engine-stuff.cpp b/libgnucash/engine/test-core/test-engine-stuff.cpp
index fff4b2a985..cc43a2f3ef 100644
--- a/libgnucash/engine/test-core/test-engine-stuff.cpp
+++ b/libgnucash/engine/test-core/test-engine-stuff.cpp
@@ -1502,7 +1502,7 @@ free_random_guids(GList *guids)
     GList *node;
 
     for (node = guids; node; node = node->next)
-        g_free (node->data);
+        guid_free (static_cast<GncGUID*>(node->data));
 
     g_list_free (guids);
 }
@@ -1732,7 +1732,7 @@ get_random_query(void)
                                    guid,
                                    get_random_id_type (),
                                    get_random_queryop ());
-            g_free (guid);
+            guid_free (guid);
             break;
 
         case 8: /* PR_KVP */

commit 2e861ab673d157ebb147693e6b9a7c70f4609764
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Sun Jun 18 15:45:56 2023 +0100

    Valgrind: fix "Mismatched free/delete" - test-dom-converters1
    
    ==32195== Mismatched free() / delete / delete []
    ==32195==    at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==32195==    by 0x146DB5: test_dom_tree_to_guid() (test-dom-converters1.cpp:251)
    ...
    ==32195==  Address 0x8043780 is 0 bytes inside a block of size 16 alloc'd
    ==32195==    at 0x4843FA3: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==32195==    by 0x503E06E: guid_malloc (guid.cpp:106)
    ==32195==    by 0x503E0D5: guid_copy (guid.cpp:123)
    ==32195==    by 0x503E1E7: guid_new (guid.cpp:154)
    ==32195==    by 0x147188: get_random_guid (test-engine-stuff.cpp:207)
    ==32195==    by 0x146D03: test_dom_tree_to_guid() (test-dom-converters1.cpp:237)
    ...

diff --git a/libgnucash/backend/xml/test/test-dom-converters1.cpp b/libgnucash/backend/xml/test/test-dom-converters1.cpp
index 2e70ab9805..a535d33073 100644
--- a/libgnucash/backend/xml/test/test-dom-converters1.cpp
+++ b/libgnucash/backend/xml/test/test-dom-converters1.cpp
@@ -248,7 +248,7 @@ test_dom_tree_to_guid (void)
                  "dom_tree_to_guid");
 
         xmlFreeNode (test_node);
-        g_free (test_guid1);
+        guid_free (test_guid1);
         guid_free (test_guid2);
     }
 }

commit e5a26e3c77f5d5d4e4443f40269768df5a90dc13
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Sat Jun 17 13:58:59 2023 +0100

    Valgrind: fix "Mismatched free/delete" - test-query
    
    ==31803== Mismatched free() / delete / delete []
    ==31803==    at 0x484620F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==31803==    by 0x1198CB: make_trans_query (test-engine-stuff.cpp:2030)
    ==31803==    by 0x115898: test_trans_query(transaction_s*, void*) (test-query.cpp:40)
    ...
    ==31803==  Address 0x7fed160 is 0 bytes inside a block of size 16 alloc'd
    ==31803==    at 0x4843FA3: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==31803==    by 0x4E3706E: guid_malloc (guid.cpp:106)
    ==31803==    by 0x4E370D5: guid_copy (guid.cpp:123)
    ==31803==    by 0x4E371E7: guid_new (guid.cpp:154)
    ==31803==    by 0x115D64: get_random_guid (test-engine-stuff.cpp:207)
    ==31803==    by 0x11984C: make_trans_query (test-engine-stuff.cpp:2023)
    ...

diff --git a/libgnucash/engine/test-core/test-engine-stuff.cpp b/libgnucash/engine/test-core/test-engine-stuff.cpp
index ce571916a1..fff4b2a985 100644
--- a/libgnucash/engine/test-core/test-engine-stuff.cpp
+++ b/libgnucash/engine/test-core/test-engine-stuff.cpp
@@ -2027,7 +2027,7 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
         xaccQueryAddAccountGUIDMatch (q, list, QOF_GUID_MATCH_ANY, QOF_QUERY_AND);
 
         for (node = list; node; node = node->next)
-            g_free (node->data);
+            guid_free (static_cast<GncGUID*>(node->data));
         g_list_free (list);
     }
 

commit 4018ff1722a29ba0b1d5e21db7c2a2b964432afb
Author: Richard Cohen <richard at daijobu.co.uk>
Date:   Thu Jun 8 16:24:37 2023 +0100

    Valgrind: fix "Mismatched free/delete" - test-kvp-frames etc.
    
    - test-kvp-frames
    - test-xml-account
    - test-xml-transaction
    - test-account-object
    - test-group-vs-book
    - test-lots
    - test-query
    - test-import-pending-matches
    
    ==30223== Mismatched free() / delete / delete []
    ==30223==    at 0x4846AFF: operator delete(void*, unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==30223==    by 0x4E370AA: guid_free (guid.cpp:116)
    ...
    ==30223==  Address 0x7ea4390 is 0 bytes inside a block of size 16 alloc'd
    ==30223==    at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==30223==    by 0x5032948: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1)
    ==30223==    by 0x11603A: get_random_guid (test-engine-stuff.cpp:209)
    ...

diff --git a/libgnucash/engine/test-core/test-engine-stuff.cpp b/libgnucash/engine/test-core/test-engine-stuff.cpp
index 05a2528e33..ce571916a1 100644
--- a/libgnucash/engine/test-core/test-engine-stuff.cpp
+++ b/libgnucash/engine/test-core/test-engine-stuff.cpp
@@ -204,12 +204,7 @@ get_random_time (void)
 GncGUID*
 get_random_guid(void)
 {
-    GncGUID *ret;
-
-    ret = g_new(GncGUID, 1);
-    guid_replace(ret);
-
-    return ret;
+    return guid_new();
 }
 
 /* ========================================================== */



Summary of changes:
 .../test/utest-split-register-copy-ops.c           | 44 ++++++++++++++++------
 .../backend/xml/test/test-dom-converters1.cpp      |  2 +-
 libgnucash/engine/test-core/test-engine-stuff.cpp  | 24 +++---------
 libgnucash/engine/test/test-customer.c             |  7 ++--
 libgnucash/engine/test/test-employee.c             |  5 ++-
 libgnucash/engine/test/test-kvp-value.cpp          |  1 +
 libgnucash/engine/test/test-vendor.c               |  5 ++-
 7 files changed, 50 insertions(+), 38 deletions(-)



More information about the gnucash-changes mailing list