From 011ebf7e0374ecb469e43f22ad7e5b42ff6c25cf Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 30 Sep 2019 11:51:50 +0200 Subject: [PATCH] Update sdb --- shlr/sdb/src/ht_inc.c | 4 ++++ shlr/sdb/src/sdb.c | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/shlr/sdb/src/ht_inc.c b/shlr/sdb/src/ht_inc.c index 66de567be2..baaad41a33 100644 --- a/shlr/sdb/src/ht_inc.c +++ b/shlr/sdb/src/ht_inc.c @@ -301,6 +301,10 @@ SDB_API HT_(Kv)* Ht_(find_kv)(HtName_(Ht)* ht, const KEY_TYPE key, bool* found) if (found) { *found = false; } + if (!ht) { + *found = false; + return NULL; + } HT_(Bucket) *bt = &ht->table[bucketfn (ht, key)]; ut32 key_len = calcsize_key (ht, key); diff --git a/shlr/sdb/src/sdb.c b/shlr/sdb/src/sdb.c index efdf6e1dde..9d4999eb2a 100644 --- a/shlr/sdb/src/sdb.c +++ b/shlr/sdb/src/sdb.c @@ -368,13 +368,12 @@ SDB_API int sdb_add(Sdb* s, const char *key, const char *val, ut32 cas) { SDB_API bool sdb_exists(Sdb* s, const char *key) { ut32 pos; char ch; - SdbKv *kv; bool found; int klen = strlen (key) + 1; if (!s) { return false; } - kv = (SdbKv*)sdb_ht_find_kvp (s->ht, key, &found); + SdbKv *kv = (SdbKv*)sdb_ht_find_kvp (s->ht, key, &found); if (found && kv) { char *v = sdbkv_value (kv); return v && *v;