werat created this revision. werat added a reviewer: labath. werat added a project: LLDB. Herald added subscribers: lldb-commits, JDevlieghere. Herald added a reviewer: JDevlieghere. werat requested review of this revision.
SBAddress constructor accepts a pointer to `lldb_private::Address`, but then dereferences it and copies the value. Allocating a temporary here leads to a memory leak. Found via ASan: Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7fc70451e19f in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10919f) #1 0x7fc6fdb560b4 in lldb::SBValue::GetAddress() /home/werat/git/llvm-project-upstream/lldb/source/API/SBValue.cpp:1359 #2 0x7fc6fdb06714 in lldb::SBType::operator=(lldb::SBType const&) /home/werat/git/llvm-project-upstream/lldb/source/API/SBType.cpp:83 ... Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D88247 Files: lldb/source/API/SBValue.cpp Index: lldb/source/API/SBValue.cpp =================================================================== --- lldb/source/API/SBValue.cpp +++ lldb/source/API/SBValue.cpp @@ -1356,7 +1356,7 @@ } } - return LLDB_RECORD_RESULT(SBAddress(new Address(addr))); + return LLDB_RECORD_RESULT(SBAddress(&addr)); } lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
Index: lldb/source/API/SBValue.cpp =================================================================== --- lldb/source/API/SBValue.cpp +++ lldb/source/API/SBValue.cpp @@ -1356,7 +1356,7 @@ } } - return LLDB_RECORD_RESULT(SBAddress(new Address(addr))); + return LLDB_RECORD_RESULT(SBAddress(&addr)); } lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits