diff --git a/libisofs/ecma119_tree.c b/libisofs/ecma119_tree.c index 9e517ad..afc3450 100644 --- a/libisofs/ecma119_tree.c +++ b/libisofs/ecma119_tree.c @@ -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); diff --git a/libisofs/util_htable.c b/libisofs/util_htable.c index 1a0a8e5..5e55273 100644 --- a/libisofs/util_htable.c +++ b/libisofs/util_htable.c @@ -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) {