From 526d73be4a3a2714fa6112769e16fb6cd0194451 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Mon, 18 Jul 2016 17:01:14 -0700 Subject: [PATCH] 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 --- tools/aapt/Images.cpp | 6 +++--- tools/aapt/Resource.cpp | 13 +++++++++++-- tools/aapt/ResourceTable.cpp | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp index 9939c188cdd9f..aea16c715b951 100644 --- a/tools/aapt/Images.cpp +++ b/tools/aapt/Images.cpp @@ -808,13 +808,13 @@ static void checkNinePatchSerialization(Res_png_9patch* inPatch, void* data) 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 e6407332bb900..a7878d196c158 100644 --- a/tools/aapt/Resource.cpp +++ b/tools/aapt/Resource.cpp @@ -326,13 +326,18 @@ static status_t makeFileResources(Bundle* bundle, const sp& assets, } 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 @@ status_t buildResources(Bundle* bundle, const sp& assets, sp sourceConfig.sdkVersion); + assert(configList != NULL); const DefaultKeyedVector>& entries = configList->getEntries(); ssize_t idx = entries.indexOfKey(sourceConfig);