summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/hash_test.c2
-rw-r--r--zix/hash.c4
2 files changed, 6 insertions, 0 deletions
diff --git a/test/hash_test.c b/test/hash_test.c
index 8b3e9de..ea808e6 100644
--- a/test/hash_test.c
+++ b/test/hash_test.c
@@ -202,6 +202,8 @@ stress(void)
int
main(void)
{
+ zix_hash_free(NULL);
+
if (stress()) {
return 1;
}
diff --git a/zix/hash.c b/zix/hash.c
index e8acfea..c4a2dba 100644
--- a/zix/hash.c
+++ b/zix/hash.c
@@ -75,6 +75,10 @@ zix_hash_new(ZixHashFunc hash_func,
ZIX_API void
zix_hash_free(ZixHash* hash)
{
+ if (!hash) {
+ return;
+ }
+
for (unsigned b = 0; b < *hash->n_buckets; ++b) {
ZixHashEntry* bucket = hash->buckets[b];
for (ZixHashEntry* e = bucket; e;) {