Skip to content

Commit

Permalink
Valgrind: fix "Invalid read" - test-kvp-value
Browse files Browse the repository at this point in the history
==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)
  • Loading branch information
richardcohen committed Jun 21, 2023
1 parent 46e6477 commit a1893ef
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions libgnucash/engine/test/test-kvp-value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down

0 comments on commit a1893ef

Please sign in to comment.