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
This commit is contained in:
parent
9d589aa0d6
commit
e76184c81f
1 changed files with 9 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue