diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2021-05-20 11:38:57 -0700 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2021-05-20 13:55:12 -0700 |
commit | 6ea9ed3d5f4673900a99c20cc4dab6fd27e60bba (patch) | |
tree | 98d8e909db68acf96f1c7d7382fa59d9330adc6a /tools | |
parent | 33517fcf9a90de9ff0be835e5bf72b656e278e29 (diff) |
Do not call pop_back when app has no uses-sdk
Calling pop_back on an empty container results in undefined behavior.
aapt2 dump badging seg faults when used on an APK with no uses-sdk.
Bug: 188461703
Test: aapt2 dump badging HelloAppTest.apk
Change-Id: I8d8308a06d542f003ae399629bdbfb5b845674fc
Diffstat (limited to 'tools')
-rw-r--r-- | tools/aapt2/dump/DumpManifest.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp index f2c6b15bc0cd..9574d275690b 100644 --- a/tools/aapt2/dump/DumpManifest.cpp +++ b/tools/aapt2/dump/DumpManifest.cpp @@ -1978,12 +1978,13 @@ bool ManifestExtractor::Dump(text::Printer* printer, IDiagnostics* diag) { filtered_uses_sdk_tags.emplace_back(uses_sdk); } } - filtered_uses_sdk_tags.pop_back(); - - root->Filter([&](const ManifestExtractor::Element* e) { - return std::find(filtered_uses_sdk_tags.begin(), filtered_uses_sdk_tags.end(), e) != - filtered_uses_sdk_tags.end(); - }); + if (filtered_uses_sdk_tags.size() >= 2U) { + filtered_uses_sdk_tags.pop_back(); + root->Filter([&](const ManifestExtractor::Element* e) { + return std::find(filtered_uses_sdk_tags.begin(), filtered_uses_sdk_tags.end(), e) != + filtered_uses_sdk_tags.end(); + }); + } // Print the elements in order seen Print(root.get(), printer); |