diff options
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 |
commit | 6d9d44aeccbfc8793d1b2e16c48b381da8c97bcf (patch) | |
tree | 1a335d4cdbdffc9db1619112a02dbcfd77812099 /libs | |
parent | 21d6871a3c1d237d4e4f11415b9b1b7b8dbe2f05 (diff) | |
parent | 06dbe50a1a138d3cde72f44036e691eb2676718d (diff) | |
download | frameworks_native-6d9d44aeccbfc8793d1b2e16c48b381da8c97bcf.zip frameworks_native-6d9d44aeccbfc8793d1b2e16c48b381da8c97bcf.tar.gz frameworks_native-6d9d44aeccbfc8793d1b2e16c48b381da8c97bcf.tar.bz2 |
Merge "Initialized check in ZipFileRO::findEntryByName" into gingerbread
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); |