From 0b224238781fdd6d11f76a30376bc1556e1d217a Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Thu, 21 Oct 2010 15:18:28 -0700 Subject: 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 --- libs/utils/ZipFileRO.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libs/utils/ZipFileRO.cpp') diff --git a/libs/utils/ZipFileRO.cpp b/libs/utils/ZipFileRO.cpp index 5ff1f8f2c928..42611964b9f5 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); -- cgit v1.2.3-59-g8ed1b