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

Commit 105fc930 authored by d34d's avatar d34d Committed by Gerrit Code Review
Browse files

Fix memory leak in AAPT

Always delete your shit!

Change-Id: If14ecedd6cced46c96bbe670b1e337def0a7edf5
REF: CYNGNOS-701
parent e34a388d
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -1284,6 +1284,9 @@ status_t preProcessImage(const Bundle* bundle, const sp<AaptAssets>& assets, //n
    png_structp write_ptr = NULL;
    png_infop write_info = NULL;

    PngMemoryFile* pmf = NULL;
    ZipFile* zip = NULL;

    status_t error = UNKNOWN_ERROR;

    const size_t nameLen = file->getPath().length();
@@ -1305,13 +1308,12 @@ status_t preProcessImage(const Bundle* bundle, const sp<AaptAssets>& assets, //n
    }

    if (isImageInZip) {
        PngMemoryFile* pmf = new PngMemoryFile();

        ZipFile* zip = new ZipFile;
        pmf = new PngMemoryFile();
        zip = new ZipFile;
        status_t err = zip->open(file->getZipFile(), ZipFile::kOpenReadOnly);
        if (NO_ERROR != err) {
            fprintf(stderr, "ERROR: Unable to open %s\n", file->getZipFile().string());
            return err;
            goto bail;
        }

        ZipEntry* entry = zip->getEntryByName(file->getSourceFile().string());
@@ -1395,6 +1397,12 @@ bail:
    if (write_ptr) {
        png_destroy_write_struct(&write_ptr, &write_info);
    }
    if (zip) {
        delete zip;
    }
    if (pmf) {
        delete pmf;
    }

    if (error != NO_ERROR) {
        fprintf(stderr, "ERROR: Failure processing PNG image %s\n",