hashtbl.c: don't call nasm_free() for a null pointer

There really isn't much point in calling nasm_free() everywhere,
even with a null pointer...

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2020-06-08 19:01:05 -07:00
parent bacf04a3e0
commit f9f37ddcfe

View File

@ -277,8 +277,9 @@ void hash_free_all(struct hash_table *head, bool free_keys)
const struct hash_node *np;
hash_for_each(head, it, np) {
nasm_free(np->data);
if (free_keys)
if (np->data)
nasm_free(np->data);
if (free_keys && np->key)
nasm_free((void *)np->key);
}