summaryrefslogtreecommitdiff
path: root/tools/aapt/Resource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/aapt/Resource.cpp')
-rw-r--r--tools/aapt/Resource.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index e6407332bb90..5f91f17b05a3 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -326,13 +326,18 @@ static status_t makeFileResources(Bundle* bundle, const sp<AaptAssets>& 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;
@@ -1028,7 +1033,6 @@ static ssize_t extractPlatformBuildVersion(AssetManager& assets, Bundle* bundle)
return NO_ERROR;
}
- ResXMLTree tree;
Asset* asset = assets.openNonAsset(cookie, "AndroidManifest.xml", Asset::ACCESS_STREAMING);
if (asset == NULL) {
fprintf(stderr, "ERROR: Platform AndroidManifest.xml not found\n");
@@ -1036,11 +1040,17 @@ static ssize_t extractPlatformBuildVersion(AssetManager& assets, Bundle* bundle)
}
ssize_t result = NO_ERROR;
- if (tree.setTo(asset->getBuffer(true), asset->getLength()) != NO_ERROR) {
- fprintf(stderr, "ERROR: Platform AndroidManifest.xml is corrupt\n");
- result = UNKNOWN_ERROR;
- } else {
- result = extractPlatformBuildVersion(tree, bundle);
+
+ // Create a new scope so that ResXMLTree is destroyed before we delete the memory over
+ // which it iterates (asset).
+ {
+ ResXMLTree tree;
+ if (tree.setTo(asset->getBuffer(true), asset->getLength()) != NO_ERROR) {
+ fprintf(stderr, "ERROR: Platform AndroidManifest.xml is corrupt\n");
+ result = UNKNOWN_ERROR;
+ } else {
+ result = extractPlatformBuildVersion(tree, bundle);
+ }
}
delete asset;
@@ -1370,6 +1380,10 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
}
}
+ if (hasErrors) {
+ return UNKNOWN_ERROR;
+ }
+
// --------------------------------------------------------------------
// Assignment of resource IDs and initial generation of resource table.
// --------------------------------------------------------------------