diff --git a/src/Db.c b/src/Db.c index ffdb51d..4255dfb 100644 --- a/src/Db.c +++ b/src/Db.c @@ -511,7 +511,7 @@ DbLockFromArr(Db * db, Array * args) } ref->name = name; - HashMapSet(db->cache, hash, ref); + HashMapSet(db->cache, UtilStringDuplicate(hash), ref); db->cacheSize += ref->size; ref->next = NULL; diff --git a/src/Json.c b/src/Json.c index d96b89a..fa4295e 100644 --- a/src/Json.c +++ b/src/Json.c @@ -645,7 +645,18 @@ JsonFree(HashMap * object) while (HashMapIterate(object, &key, (void **) &value)) { - Free(key); + /* + * The key might not always be on the heap. In cases + * where the JSON object is built programmatically instead + * of with the parser, stack strings will probably have been + * used as the key. + */ + MemoryInfo *i = MemoryInfoGet(key); + if (i) + { + Free(key); + } + JsonValueFree(value); }