[Lldb-commits] [PATCH] D42347: Fix memory leaks in MinidumpParserTest
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sat Jan 20 23:39:53 PST 2018
teemperor created this revision.
teemperor added a reviewer: dvlahovski.
We never delete the allocated RegisterContext objects, causing those tests to fail with enabled memory sanitizer.
https://reviews.llvm.org/D42347
Files:
unittests/Process/minidump/MinidumpParserTest.cpp
Index: unittests/Process/minidump/MinidumpParserTest.cpp
===================================================================
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -315,9 +315,10 @@
llvm::ArrayRef<uint8_t> registers(parser->GetThreadContext(thread));
ArchSpec arch = parser->GetArchitecture();
- RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+ std::unique_ptr<RegisterInfoInterface> reg_interface(
+ new RegisterContextLinux_i386(arch));
lldb::DataBufferSP buf =
- ConvertMinidumpContext_x86_32(registers, reg_interface);
+ ConvertMinidumpContext_x86_32(registers, reg_interface.get());
ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -357,9 +358,10 @@
llvm::ArrayRef<uint8_t> registers(parser->GetThreadContext(thread));
ArchSpec arch = parser->GetArchitecture();
- RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+ std::unique_ptr<RegisterInfoInterface> reg_interface(
+ new RegisterContextLinux_x86_64(arch));
lldb::DataBufferSP buf =
- ConvertMinidumpContext_x86_64(registers, reg_interface);
+ ConvertMinidumpContext_x86_64(registers, reg_interface.get());
ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -407,9 +409,10 @@
llvm::ArrayRef<uint8_t> registers(parser->GetThreadContextWow64(thread));
ArchSpec arch = parser->GetArchitecture();
- RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+ std::unique_ptr<RegisterInfoInterface> reg_interface(
+ new RegisterContextLinux_i386(arch));
lldb::DataBufferSP buf =
- ConvertMinidumpContext_x86_32(registers, reg_interface);
+ ConvertMinidumpContext_x86_32(registers, reg_interface.get());
ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42347.130797.patch
Type: text/x-patch
Size: 2093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180121/cb419944/attachment-0001.bin>
More information about the lldb-commits
mailing list