diff options
| author | Kenny Root <kroot@google.com> | 2010-09-24 09:11:28 -0700 |
|---|---|---|
| committer | Alex Ray <aray@google.com> | 2013-07-30 13:56:55 -0700 |
| commit | cea2778d14a84e4dff261b82f5d8d9badfaafa85 (patch) | |
| tree | 3b785e3678fed59d3853d147d6666604d2c48b6a | |
| parent | f7c1be0e62dea8a3f8b2d9b97689de964484f4db (diff) | |
| download | system_core-cea2778d14a84e4dff261b82f5d8d9badfaafa85.zip system_core-cea2778d14a84e4dff261b82f5d8d9badfaafa85.tar.gz system_core-cea2778d14a84e4dff261b82f5d8d9badfaafa85.tar.bz2 | |
Revert "Revert "Free created FileMap when uncompressing files""
This revert reverts commit a19ef306bd0a257c67b50f5e0e669e9fe52b0889.
| -rw-r--r-- | libs/utils/ZipFileRO.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libs/utils/ZipFileRO.cpp b/libs/utils/ZipFileRO.cpp index 59809c2..9fcae72 100644 --- a/libs/utils/ZipFileRO.cpp +++ b/libs/utils/ZipFileRO.cpp @@ -643,7 +643,7 @@ bool ZipFileRO::uncompressEntry(ZipEntryRO entry, void* buffer) const memcpy(buffer, ptr, uncompLen); } else { if (!inflateBuffer(buffer, ptr, uncompLen, compLen)) - goto bail; + goto unmap; } if (compLen > kSequentialMin) @@ -651,6 +651,8 @@ bool ZipFileRO::uncompressEntry(ZipEntryRO entry, void* buffer) const result = true; +unmap: + file->release(); bail: return result; } @@ -674,7 +676,7 @@ bool ZipFileRO::uncompressEntry(ZipEntryRO entry, int fd) const getEntryInfo(entry, &method, &uncompLen, &compLen, &offset, NULL, NULL); - const FileMap* file = createEntryFileMap(entry); + FileMap* file = createEntryFileMap(entry); if (file == NULL) { goto bail; } @@ -685,21 +687,23 @@ bool ZipFileRO::uncompressEntry(ZipEntryRO entry, int fd) const ssize_t actual = write(fd, ptr, uncompLen); if (actual < 0) { LOGE("Write failed: %s\n", strerror(errno)); - goto bail; + goto unmap; } else if ((size_t) actual != uncompLen) { LOGE("Partial write during uncompress (%zd of %zd)\n", (size_t)actual, (size_t)uncompLen); - goto bail; + goto unmap; } else { LOGI("+++ successful write\n"); } } else { if (!inflateBuffer(fd, ptr, uncompLen, compLen)) - goto bail; + goto unmap; } result = true; +unmap: + file->release(); bail: return result; } |
