Bug fix: Prevent allocation of empty hash tables. Thanks Richard Nolde.
This commit is contained in:
parent
03b45c3151
commit
0e00aeb638
@ -592,6 +592,9 @@ int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
|
|||||||
nchildren = dir->info.dir->nchildren;
|
nchildren = dir->info.dir->nchildren;
|
||||||
children = dir->info.dir->children;
|
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 */
|
/* a hash table will temporary hold the names, for fast searching */
|
||||||
ret = iso_htable_create((nchildren * 100) / 80, iso_str_hash,
|
ret = iso_htable_create((nchildren * 100) / 80, iso_str_hash,
|
||||||
(compare_function_t)strcmp, &table);
|
(compare_function_t)strcmp, &table);
|
||||||
|
@ -322,9 +322,10 @@ int iso_htable_create(size_t size, hash_funtion_t hash,
|
|||||||
{
|
{
|
||||||
IsoHTable *t;
|
IsoHTable *t;
|
||||||
|
|
||||||
if (table == NULL) {
|
if (size <= 0)
|
||||||
return ISO_OUT_OF_MEM;
|
return ISO_WRONG_ARG_VALUE;
|
||||||
}
|
if (table == NULL)
|
||||||
|
return ISO_NULL_POINTER;
|
||||||
|
|
||||||
t = malloc(sizeof(IsoHTable));
|
t = malloc(sizeof(IsoHTable));
|
||||||
if (t == NULL) {
|
if (t == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user