AAPT: Don't keep processing files that failed to be added
AAPT will continue ahead without reporting an error if a file
failed to be added to the ResourceTable. This would cause crashes
later when the file was assumed to be present.
Bug:30200166
Change-Id: Ieb2daf97ccf0345153b6f4598d130a38d108c937
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp
index 9939c18..aea16c7 100644
--- a/tools/aapt/Images.cpp
+++ b/tools/aapt/Images.cpp
@@ -808,13 +808,13 @@
assert(outPatch->paddingTop == inPatch->paddingTop);
assert(outPatch->paddingBottom == inPatch->paddingBottom);
for (int i = 0; i < outPatch->numXDivs; i++) {
- assert(outPatch->xDivs[i] == inPatch->xDivs[i]);
+ assert(outPatch->getXDivs()[i] == inPatch->getXDivs()[i]);
}
for (int i = 0; i < outPatch->numYDivs; i++) {
- assert(outPatch->yDivs[i] == inPatch->yDivs[i]);
+ assert(outPatch->getYDivs()[i] == inPatch->getYDivs()[i]);
}
for (int i = 0; i < outPatch->numColors; i++) {
- assert(outPatch->colors[i] == inPatch->colors[i]);
+ assert(outPatch->getColors()[i] == inPatch->getColors()[i]);
}
free(newData);
}
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index e640733..a7878d1 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -326,13 +326,18 @@
}
String8 resPath = it.getPath();
resPath.convertToResPath();
- table->addEntry(SourcePos(it.getPath(), 0), String16(assets->getPackage()),
+ status_t result = table->addEntry(SourcePos(it.getPath(), 0),
+ String16(assets->getPackage()),
type16,
baseName,
String16(resPath),
NULL,
&it.getParams());
- assets->addResource(it.getLeafName(), resPath, it.getFile(), type8);
+ if (result != NO_ERROR) {
+ hasErrors = true;
+ } else {
+ assets->addResource(it.getLeafName(), resPath, it.getFile(), type8);
+ }
}
return hasErrors ? STATUST(UNKNOWN_ERROR) : NO_ERROR;
@@ -1370,6 +1375,10 @@
}
}
+ if (hasErrors) {
+ return UNKNOWN_ERROR;
+ }
+
// --------------------------------------------------------------------
// Assignment of resource IDs and initial generation of resource table.
// --------------------------------------------------------------------
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 6a4b637..6d80a69 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -4521,6 +4521,7 @@
const ConfigDescription& sourceConfig,
const int sdkVersionToGenerate) {
assert(sdkVersionToGenerate > sourceConfig.sdkVersion);
+ assert(configList != NULL);
const DefaultKeyedVector<ConfigDescription, sp<ResourceTable::Entry>>& entries
= configList->getEntries();
ssize_t idx = entries.indexOfKey(sourceConfig);