Skip to content

Commit

Permalink
Valgrind: fix "Invalid read" - test-customer
Browse files Browse the repository at this point in the history
==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)
...
  • Loading branch information
richardcohen committed Jun 21, 2023
1 parent a1893ef commit a5513b4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libgnucash/engine/test/test-customer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit a5513b4

Please sign in to comment.