Commit 01a83d0a authored by Salvatore Sanfilippo's avatar Salvatore Sanfilippo
Browse files

Merge pull request #3239 from dvirsky/fix_hashset_crash

fixed bad transfer of ownership in HashSet causing a potential crash
parents bee963c4 cfaef8d5
......@@ -1795,10 +1795,13 @@ int RM_HashSet(RedisModuleKey *key, int flags, ...) {
if (flags & REDISMODULE_HASH_CFIELDS)
low_flags |= HASH_SET_TAKE_FIELD;
updated += hashTypeSet(key->value, field->ptr, value->ptr, low_flags);
field->ptr = NULL; /* Ownership is now of hashTypeSet() */
/* Cleanup */
if (flags & REDISMODULE_HASH_CFIELDS) decrRefCount(field);
/* If CFIELDS is active, ownership is now of hashTypeSet() */
if (flags & REDISMODULE_HASH_CFIELDS) {
field->ptr = NULL;
/* Cleanup */
decrRefCount(field);
}
}
va_end(ap);
moduleDelKeyIfEmpty(key);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment