summaryrefslogtreecommitdiff
path: root/libs/utils/ZipFileRO.cpp
diff options
context:
space:
mode:
author Kenny Root <kroot@google.com> 2010-10-22 07:55:44 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2010-10-22 07:55:44 -0700
commit8ad30b5b7e380428701a44458393cbc2381f205b (patch)
treebc0c80f21bd9d146bee842a08c71d601b931f8c9 /libs/utils/ZipFileRO.cpp
parent1257d330dcfdb87214278c8fc9718ea9fc663df6 (diff)
parent0b224238781fdd6d11f76a30376bc1556e1d217a (diff)
Merge "Initialized check in ZipFileRO::findEntryByName" into gingerbread
Diffstat (limited to 'libs/utils/ZipFileRO.cpp')
-rw-r--r--libs/utils/ZipFileRO.cpp10
1 files changed, 9 insertions, 1 deletions
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);