Fixed leak of unloaded module lists.

BUG=

Change-Id: I6d03820082f793a2eac3c3c2abd184b4acf66aa4
Reviewed-on: https://chromium-review.googlesource.com/438755
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
This commit is contained in:
Joshua Peraza 2017-02-07 12:12:53 -08:00
parent 7ba80c7284
commit 64c2eda38a
2 changed files with 6 additions and 2 deletions

View File

@ -84,6 +84,7 @@ class MockMinidumpUnloadedModuleList : public MinidumpUnloadedModuleList {
public: public:
MockMinidumpUnloadedModuleList() : MinidumpUnloadedModuleList(NULL) {} MockMinidumpUnloadedModuleList() : MinidumpUnloadedModuleList(NULL) {}
~MockMinidumpUnloadedModuleList() {}
MOCK_CONST_METHOD0(Copy, CodeModules*()); MOCK_CONST_METHOD0(Copy, CodeModules*());
MOCK_CONST_METHOD1(GetModuleForAddress, MOCK_CONST_METHOD1(GetModuleForAddress,
const MinidumpUnloadedModule*(uint64_t)); const MinidumpUnloadedModule*(uint64_t));
@ -400,11 +401,13 @@ TEST_F(MinidumpProcessorTest, TestUnloadedModules) {
EXPECT_CALL(memory_list, GetMemoryRegionForAddress(_)). EXPECT_CALL(memory_list, GetMemoryRegionForAddress(_)).
Times(0); Times(0);
MockMinidumpUnloadedModuleList* unloaded_module_list_copy =
new MockMinidumpUnloadedModuleList();
EXPECT_CALL(unloaded_module_list, Copy()). EXPECT_CALL(unloaded_module_list, Copy()).
WillOnce(Return(&unloaded_module_list)); WillOnce(Return(unloaded_module_list_copy));
MockMinidumpUnloadedModule unloaded_module; MockMinidumpUnloadedModule unloaded_module;
EXPECT_CALL(unloaded_module_list, GetModuleForAddress(kExpectedEIP)). EXPECT_CALL(*unloaded_module_list_copy, GetModuleForAddress(kExpectedEIP)).
WillOnce(Return(&unloaded_module)); WillOnce(Return(&unloaded_module));
MinidumpProcessor processor(reinterpret_cast<SymbolSupplier*>(NULL), NULL); MinidumpProcessor processor(reinterpret_cast<SymbolSupplier*>(NULL), NULL);

View File

@ -64,6 +64,7 @@ void ProcessState::Clear() {
modules_with_corrupt_symbols_.clear(); modules_with_corrupt_symbols_.clear();
delete modules_; delete modules_;
modules_ = NULL; modules_ = NULL;
delete unloaded_modules_;
unloaded_modules_ = NULL; unloaded_modules_ = NULL;
} }