Skip to content

Commit

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

0 comments on commit 2168c6f

Please sign in to comment.