From 35388e93f7dc45257bbffc675710728aeb663394 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Tue, 5 Aug 2014 15:43:13 -0700 Subject: [PATCH] Check for a NULL pointer, do not call Build. When calling BacktraceMap::Create(), a NULL pointer is returned if Build fails. Building twice can cause problems and might leak memory. (cherry picked from commit 836572a07142627ff291d686a4e9e03a0988344b) Change-Id: I59d29bb6e5324de6eb099916045c2ab1d9e56630 --- runtime/mem_map.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc index 6c7ee5b7d..c281b2200 100644 --- a/runtime/mem_map.cc +++ b/runtime/mem_map.cc @@ -135,7 +135,7 @@ static bool CheckOverlapping(uintptr_t begin, uintptr_t end, std::string* error_msg) { std::unique_ptr map(BacktraceMap::Create(getpid(), true)); - if (!map->Build()) { + if (map.get() == nullptr) { *error_msg = StringPrintf("Failed to build process map"); return false; } @@ -158,7 +158,7 @@ static bool CheckNonOverlapping(uintptr_t begin, uintptr_t end, std::string* error_msg) { std::unique_ptr map(BacktraceMap::Create(getpid(), true)); - if (!map->Build()) { + if (map.get() == nullptr) { *error_msg = StringPrintf("Failed to build process map"); return false; } -- 2.11.0