From 4e6af16ef6c3d166ac07bca007533fe787e533b5 Mon Sep 17 00:00:00 2001 From: Nick Hahn Date: Wed, 23 Oct 2019 11:25:51 +0200 Subject: [PATCH] Guard hashmap_put from copying into NULL pointer --- hashmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hashmap.c b/hashmap.c index 3978400..0ceea56 100644 --- a/hashmap.c +++ b/hashmap.c @@ -311,7 +311,8 @@ int hashmap_get(map_t in, char* key, any_t *arg){ curr = (curr + 1) % m->table_size; } - *arg = NULL; + if(arg != NULL) + *arg = NULL; /* Not found */ return MAP_MISSING; @@ -394,4 +395,4 @@ int hashmap_length(map_t in){ hashmap_map* m = (hashmap_map *) in; if(m != NULL) return m->size; else return 0; -} \ No newline at end of file +}