From 8f52340766ec64e2e5248ee1199b006e17e222c3 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Mon, 22 Jan 2018 09:48:40 +0000 Subject: [PATCH] Fix memory leaks in MinidumpParserTest Summary: We never delete the allocated RegisterContext objects, causing those tests to fail with enabled memory sanitizer. Reviewers: dvlahovski, zturner Reviewed By: zturner Subscribers: zturner, lldb-commits Differential Revision: https://reviews.llvm.org/D42347 llvm-svn: 323085 --- .../Process/minidump/MinidumpParserTest.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lldb/unittests/Process/minidump/MinidumpParserTest.cpp b/lldb/unittests/Process/minidump/MinidumpParserTest.cpp index 7aceb0e16dcf..efd0ab3dbba4 100644 --- a/lldb/unittests/Process/minidump/MinidumpParserTest.cpp +++ b/lldb/unittests/Process/minidump/MinidumpParserTest.cpp @@ -315,9 +315,9 @@ TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32) { llvm::ArrayRef registers(parser->GetThreadContext(thread)); ArchSpec arch = parser->GetArchitecture(); - RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch); + auto reg_interface = llvm::make_unique(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 +357,9 @@ TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_64) { llvm::ArrayRef registers(parser->GetThreadContext(thread)); ArchSpec arch = parser->GetArchitecture(); - RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch); + auto reg_interface = llvm::make_unique(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 +407,9 @@ TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32_wow64) { llvm::ArrayRef registers(parser->GetThreadContextWow64(thread)); ArchSpec arch = parser->GetArchitecture(); - RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch); + auto reg_interface = llvm::make_unique(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();