From 1e1f6365140418026522a5b79bf1e90d919bf53e Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 5 Aug 2018 21:27:24 +0000 Subject: [PATCH] hashtable: fix ko_hashtable_set when appending to a bucket --- lib/hashtable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/hashtable.c b/lib/hashtable.c index 799a22e..2d0d7d6 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -57,9 +57,10 @@ void *ko_hashtable_set(struct ko_hashtable *table, const char *key, void *value) entry = calloc(1, sizeof(struct ko_hashtable_entry)); entry->hash = hash; entry->key = strdup(key); - table->buckets[bucket] = entry; if (previous) { previous->next = entry; + } else { + table->buckets[bucket] = entry; } } -- 2.38.5