OSDN Git Service

Check value in dump before printing
authorRyan Mitchell <rtmitchell@google.com>
Mon, 15 Apr 2019 23:47:58 +0000 (16:47 -0700)
committerRyan Mitchell <rtmitchell@google.com>
Tue, 16 Apr 2019 19:00:30 +0000 (12:00 -0700)
For applications that remove the names of resources from the string
pool, check that the attribute has a name before attempting to print it.

Test: manual
Bug: 130553900
Change-Id: I05e5d59f01b2c02c8a024d06fd896074d6bf465b

tools/aapt2/Debug.cpp

index 9832485..3da22b4 100644 (file)
@@ -129,12 +129,20 @@ class ValueBodyPrinter : public ConstValueVisitor {
     constexpr uint32_t kMask = android::ResTable_map::TYPE_ENUM | android::ResTable_map::TYPE_FLAGS;
     if (attr->type_mask & kMask) {
       for (const auto& symbol : attr->symbols) {
-        printer_->Print(symbol.symbol.name.value().entry);
-        if (symbol.symbol.id) {
-          printer_->Print("(");
+        if (symbol.symbol.name) {
+          printer_->Print(symbol.symbol.name.value().entry);
+
+          if (symbol.symbol.id) {
+            printer_->Print("(");
+            printer_->Print(symbol.symbol.id.value().to_string());
+            printer_->Print(")");
+          }
+        } else if (symbol.symbol.id) {
           printer_->Print(symbol.symbol.id.value().to_string());
-          printer_->Print(")");
+        } else {
+          printer_->Print("???");
         }
+
         printer_->Println(StringPrintf("=0x%08x", symbol.value));
       }
     }