From bc1b4885de3a80accda894c51c361e2009d54210 Mon Sep 17 00:00:00 2001 From: Stuart Reilly Date: Fri, 28 Jun 2019 16:00:32 +0100 Subject: Fix potential NULL deref in libcache --- src/lib/third_party/src/libcache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/third_party/src/libcache.c b/src/lib/third_party/src/libcache.c index 4479ff54d..597684ccc 100644 --- a/src/lib/third_party/src/libcache.c +++ b/src/lib/third_party/src/libcache.c @@ -196,7 +196,11 @@ cache_result cache_add(cache_t cache, void *item, uint32_t item_size) { } if(hash_entry_map_prev) { - hash_entry_map_prev->next = hash_entry_map->next; + if (hash_entry_map) { + hash_entry_map_prev->next = hash_entry_map->next; + } else { + hash_entry_map_prev->next = NULL; + } } else { cache->map[hash] = hash_entry_map->next; } -- cgit v1.2.3