diff options
author | Florian Mayer <fmayer@google.com> | 2019-02-27 18:00:37 +0000 |
---|---|---|
committer | Florian Mayer <fmayer@google.com> | 2019-03-05 13:05:36 +0000 |
commit | 0845cd5af61856f523cb3091b82829e44383b16e (patch) | |
tree | c7ecab5fa65f85da694c7fd88624697d82bb2668 /libunwindstack/Global.cpp | |
parent | c7950cad2000f7040b7fbe29d3b9f40a21ec476b (diff) | |
download | unwinding-0845cd5af61856f523cb3091b82829e44383b16e.tar.gz |
Fix copy / move behaviour of Maps object.
Currently, moving or copying a Maps object leads to double free of MapInfo.
Even moving a Maps object did not prevent this, as after a move
the object only has to be in an "unspecified but valid state", which can
be the original state for a vector of raw pointers (but not for a vector
of unique_ptrs).
Changing to unique_ptrs is the most failsafe way to make sure we never
accidentally destruct MapInfo.
Test: atest libuwindstack_test
Failed LocalUnwinderTest#unwind_after_dlopen which also fails at master.
Change-Id: Id1c9739b334da5c1ba532fd55366e115940a66d3
Diffstat (limited to 'libunwindstack/Global.cpp')
-rw-r--r-- | libunwindstack/Global.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libunwindstack/Global.cpp b/libunwindstack/Global.cpp index fdfd705..a20be00 100644 --- a/libunwindstack/Global.cpp +++ b/libunwindstack/Global.cpp @@ -77,7 +77,7 @@ void Global::FindAndReadVariable(Maps* maps, const char* var_str) { // f0000-f2000 0 r-- /system/lib/libc.so // f2000-f3000 2000 rw- /system/lib/libc.so MapInfo* map_start = nullptr; - for (MapInfo* info : *maps) { + for (const auto& info : *maps) { if (map_start != nullptr) { if (map_start->name == info->name) { if (info->offset != 0 && @@ -96,7 +96,7 @@ void Global::FindAndReadVariable(Maps* maps, const char* var_str) { } if (map_start == nullptr && (info->flags & PROT_READ) && info->offset == 0 && !info->name.empty()) { - map_start = info; + map_start = info.get(); } } } |