AAPT: Fix use-after-free error am: 193ed74c2d am: 646f2d9c33

am: 9e8da4a476

Change-Id: I591fd51bf456cd42fe8c633de8924a9f2c844866
This commit is contained in:
Adam Lesinski
2016-08-15 23:33:01 +00:00
committed by android-build-merger

View File

@@ -1033,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");
@@ -1041,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;