Bug fix: Prevent allocation of empty hash tables. Thanks Richard Nolde.

This commit is contained in:
Thomas Schmitt 2014-04-02 18:40:03 +02:00
parent 03b45c3151
commit 0e00aeb638
2 changed files with 7 additions and 3 deletions

View File

@ -592,6 +592,9 @@ int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
nchildren = dir->info.dir->nchildren;
children = dir->info.dir->children;
if (nchildren <= 0)
return ISO_SUCCESS; /* nothing to do */
/* a hash table will temporary hold the names, for fast searching */
ret = iso_htable_create((nchildren * 100) / 80, iso_str_hash,
(compare_function_t)strcmp, &table);

View File

@ -322,9 +322,10 @@ int iso_htable_create(size_t size, hash_funtion_t hash,
{
IsoHTable *t;
if (table == NULL) {
return ISO_OUT_OF_MEM;
}
if (size <= 0)
return ISO_WRONG_ARG_VALUE;
if (table == NULL)
return ISO_NULL_POINTER;
t = malloc(sizeof(IsoHTable));
if (t == NULL) {