diff options
-rw-r--r-- | tools/aapt/Images.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp index 528a960..2bf7e9c 100644 --- a/tools/aapt/Images.cpp +++ b/tools/aapt/Images.cpp @@ -1317,6 +1317,9 @@ status_t preProcessImage(const Bundle* bundle, const sp<AaptAssets>& /* assets * 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(); @@ -1332,13 +1335,12 @@ status_t preProcessImage(const Bundle* bundle, const sp<AaptAssets>& /* assets * } 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()); @@ -1417,6 +1419,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", |