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

Commit d5207b2e authored by Romain Guy's avatar Romain Guy
Browse files

Fix double-free in AssetAtlas

Bug #8833153

If Atlas::terminate() is called twice without an init() in between
libhwui would double-free Atlas::mImage. This lead to a lot of crashes
with the monkeys as they can easily trigger memory trims.

Change-Id: I96798414e5e71cd498aaca85a790661ebccdaa91
parent 2ae118d1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -39,13 +39,17 @@ void AssetAtlas::init(sp<GraphicBuffer> buffer, int* map, int count) {

        createEntries(map, count);
    } else {
        ALOGW("Could not create atlas image");

        delete mImage;
        mImage = NULL;
    }
}

void AssetAtlas::terminate() {
    if (mImage) {
        delete mImage;
        mImage = NULL;

        for (size_t i = 0; i < mEntries.size(); i++) {
            delete mEntries.valueAt(i);