[nasm:nasm-2.15.xx] hashtbl.c: don't call nasm_free() for a null pointer
nasm-bot for H. Peter Anvin (Intel)
hpa at zytor.com
Mon Jun 8 19:06:10 PDT 2020
Commit-ID: f9f37ddcfeb918420c2b019a56a2b97280f677a8
Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=f9f37ddcfeb918420c2b019a56a2b97280f677a8
Author: H. Peter Anvin (Intel) <hpa at zytor.com>
AuthorDate: Mon, 8 Jun 2020 19:01:05 -0700
Committer: H. Peter Anvin (Intel) <hpa at zytor.com>
CommitDate: Mon, 8 Jun 2020 19:01:05 -0700
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 at zytor.com>
---
nasmlib/hashtbl.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/nasmlib/hashtbl.c b/nasmlib/hashtbl.c
index 3f4a957c..9a4c0b55 100644
--- a/nasmlib/hashtbl.c
+++ b/nasmlib/hashtbl.c
@@ -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);
}
More information about the Nasm-commits
mailing list