diff options
author | Kenny Root <kroot@google.com> | 2010-08-20 13:16:20 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-08-20 13:16:20 -0700 |
commit | e6d429c49bee4649d7d0b47ba0cccd13dac14c17 (patch) | |
tree | 4e2e82d02f17f140775c286aaa41f23769c4fb18 /libs | |
parent | 047dca2130f10e3cf7b1929e24241315fafe2bad (diff) | |
parent | cd9ce313ddc9aa326271bf4ecea7af9b26e73b79 (diff) | |
download | frameworks_native-e6d429c49bee4649d7d0b47ba0cccd13dac14c17.zip frameworks_native-e6d429c49bee4649d7d0b47ba0cccd13dac14c17.tar.gz frameworks_native-e6d429c49bee4649d7d0b47ba0cccd13dac14c17.tar.bz2 |
Merge "Free created FileMap when uncompressing files" into gingerbread
Diffstat (limited to 'libs')
-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 a4c3500..604f558 100644 --- a/libs/utils/ZipFileRO.cpp +++ b/libs/utils/ZipFileRO.cpp @@ -636,7 +636,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) @@ -644,6 +644,8 @@ bool ZipFileRO::uncompressEntry(ZipEntryRO entry, void* buffer) const result = true; +unmap: + file->release(); bail: return result; } @@ -667,7 +669,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; } @@ -678,21 +680,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; } |