diff options
author | d34d <clark@cyngn.com> | 2015-08-05 19:37:35 -0700 |
---|---|---|
committer | Clark Scheff <clark@cyngn.com> | 2015-10-27 18:22:35 -0700 |
commit | c9b365d67b866896b27bedcd357629d6cf48e526 (patch) | |
tree | 297cb00d8c833b66ad50ee060400f92c0b123859 /tools/aapt | |
parent | 47e32697f94de0836309221a1b1c20c20eed3581 (diff) | |
download | frameworks_base-c9b365d67b866896b27bedcd357629d6cf48e526.zip frameworks_base-c9b365d67b866896b27bedcd357629d6cf48e526.tar.gz frameworks_base-c9b365d67b866896b27bedcd357629d6cf48e526.tar.bz2 |
Fix memory leak in AAPT
Always delete your shit!
Change-Id: If14ecedd6cced46c96bbe670b1e337def0a7edf5
REF: CYNGNOS-701
Diffstat (limited to 'tools/aapt')
-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", |