diff options
author | Kenny Root <kroot@google.com> | 2010-10-21 15:18:28 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2010-10-21 15:25:12 -0700 |
commit | 06dbe50a1a138d3cde72f44036e691eb2676718d (patch) | |
tree | fbfbb60b613c628b938d6e20c2895178b72f9cc7 /libs | |
parent | e739a5257d7c02b987d9b16046407797f83d1a7d (diff) | |
download | frameworks_native-06dbe50a1a138d3cde72f44036e691eb2676718d.zip frameworks_native-06dbe50a1a138d3cde72f44036e691eb2676718d.tar.gz frameworks_native-06dbe50a1a138d3cde72f44036e691eb2676718d.tar.bz2 |
Initialized check in ZipFileRO::findEntryByName
If a ZipFileRO object is uninitialized, the hash table will not have
been initialized. This condition wasn't checked in findEntryByName.
Bug: 3121109
Change-Id: Ib696e0e7e0cb4dd0fb2e456d6a847e5e8f4fe14e
Diffstat (limited to 'libs')
-rw-r--r-- | libs/utils/ZipFileRO.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libs/utils/ZipFileRO.cpp b/libs/utils/ZipFileRO.cpp index 5ff1f8f..4261196 100644 --- a/libs/utils/ZipFileRO.cpp +++ b/libs/utils/ZipFileRO.cpp @@ -412,10 +412,18 @@ void ZipFileRO::addToHash(const char* str, int strLen, unsigned int hash) /* * Find a matching entry. * - * Returns 0 if not found. + * Returns NULL if not found. */ ZipEntryRO ZipFileRO::findEntryByName(const char* fileName) const { + /* + * If the ZipFileRO instance is not initialized, the entry number will + * end up being garbage since mHashTableSize is -1. + */ + if (mHashTableSize <= 0) { + return NULL; + } + int nameLen = strlen(fileName); unsigned int hash = computeHash(fileName, nameLen); int ent = hash & (mHashTableSize-1); |