diff --git a/shlr/sdb/src/ht.c b/shlr/sdb/src/ht.c index 9828a27481..3020be1df3 100644 --- a/shlr/sdb/src/ht.c +++ b/shlr/sdb/src/ht.c @@ -299,9 +299,6 @@ SDB_API void ht_foreach(SdbHt *ht, HtForeachCallback cb, void *user) { SdbListIter *iter, *tmp; for (i = 0; i < ht->size; i++) { ls_foreach_safe (ht->table[i], iter, tmp, kv) { - if (!kv) { - continue; - } if (!cb (user, kv->key, kv->value)) { return; } diff --git a/shlr/sdb/src/sdb.c b/shlr/sdb/src/sdb.c index 64209b2b61..2d9288d211 100644 --- a/shlr/sdb/src/sdb.c +++ b/shlr/sdb/src/sdb.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2011-2017 - pancake */ +/* sdb - MIT - Copyright 2011-2018 - pancake */ #include #include @@ -296,6 +296,7 @@ SDB_API int sdb_uncat(Sdb *s, const char *key, const char *value, ut32 cas) { char *p, *v = sdb_get_len (s, key, &vlen, NULL); int mod = 0; if (!v || !key || !value) { + free (v); return 0; } valen = strlen (value); @@ -512,9 +513,11 @@ SDB_API SdbKv* sdbkv_new2(const char *k, int kl, const char *v, int vl) { } SDB_API void sdbkv_free(SdbKv *kv) { - free (sdbkv_key (kv)); - free (sdbkv_value (kv)); - R_FREE (kv); + if (kv) { + free (sdbkv_key (kv)); + free (sdbkv_value (kv)); + R_FREE (kv); + } } static ut32 sdb_set_internal(Sdb* s, const char *key, char *val, int owned, ut32 cas) {