Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e8da4a4 authored by Adam Lesinski's avatar Adam Lesinski Committed by android-build-merger
Browse files

AAPT: Fix use-after-free error am: 193ed74c

am: 646f2d9c

Change-Id: If9fe7a52e62ae6b2900aa187996b4b785894ab03
parents f0cbd624 646f2d9c
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -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,12 +1040,18 @@ static ssize_t extractPlatformBuildVersion(AssetManager& assets, Bundle* bundle)
    }

    ssize_t result = NO_ERROR;

    // 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;
    return result;