Don't dump data from a bad ResTable

AAPT dumps data from a bad ResTable, which
causes crashes. Prevent this by checking if
there were errors when creating the ResTable.

Bug:14902008
Change-Id: I5e04ebf967c60b78c511dd175785a13bca52f09a
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 4e0a9fe..cc0da15 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -634,6 +634,9 @@
     if (&res == NULL) {
         fprintf(stderr, "ERROR: dump failed because no resource table was found\n");
         goto bail;
+    } else if (res.getError() != NO_ERROR) {
+        fprintf(stderr, "ERROR: dump failed because the resource table is invalid/corrupt.\n");
+        goto bail;
     }
 
     if (strcmp("resources", option) == 0) {
diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp
index 158b391..06769e4 100644
--- a/tools/aapt/StringPool.cpp
+++ b/tools/aapt/StringPool.cpp
@@ -33,6 +33,14 @@
 
 void printStringPool(const ResStringPool* pool)
 {
+    if (pool->getError() == NO_INIT) {
+        printf("String pool is unitialized.\n");
+        return;
+    } else if (pool->getError() != NO_ERROR) {
+        printf("String pool is corrupt/invalid.\n");
+        return;
+    }
+
     SortedVector<const void*> uniqueStrings;
     const size_t N = pool->size();
     for (size_t i=0; i<N; i++) {