diff options
author | Kelvin Zhang <zhangkelvin@google.com> | 2021-05-10 12:17:14 -0400 |
---|---|---|
committer | Kelvin Zhang <zhangkelvin@google.com> | 2021-05-11 17:18:45 +0000 |
commit | 3965584d3a988e9a551ce0d96812f3923e01b0b5 (patch) | |
tree | 4baa42f33e58441d59a4f814f87ab356bcf98dcb | |
parent | b61fb4ee86c70ea34da9e0a05e4c65421a40dedf (diff) |
Fix segmentation fault in aapt2
When passing a single iterator to std::vector::eraase, only element at
that iterator is removed. If no elements are filtered, std::remove_if()
returns the end iterator, attempting to erase() the end iterator can
cause segmentation fault. This bug causes signing test to fail.
https://atp.googleplex.com/tests/asit/ota/signing?tabId=test_run
Test: aapt2
PRODUCT/app/CalculatorGooglePrebuilt/CalculatorGooglePrebuilt.apk
Bug: 175789289
Bug: 178554651
Change-Id: I813055238bef2dcbdf76172a00b3f44ae940b759
(cherry picked from commit b88ccf80aa884df039cd13c5a31f3e08065d487e)
-rw-r--r-- | tools/aapt2/dump/DumpManifest.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp index 61ba09b6a3c9..f2c6b15bc0cd 100644 --- a/tools/aapt2/dump/DumpManifest.cpp +++ b/tools/aapt2/dump/DumpManifest.cpp @@ -135,7 +135,8 @@ class ManifestExtractor { template <typename Predicate> void Filter(Predicate&& func) { children_.erase(std::remove_if(children_.begin(), children_.end(), - [&](const auto& e) { return func(e.get()); })); + [&](const auto& e) { return func(e.get()); }), + children_.end()); } /** Retrieves the list of children of the element. */ |