Fix memory leak in RM_StreamIteratorStop and moduleFreeKeyIterator (#10353)

* Fix memory leak in RM_StreamIteratorStop
* Fix memory leak in moduleFreeKeyIterator
This commit is contained in:
Vitah Lin 2022-02-28 23:06:39 +08:00 committed by GitHub
parent 9478d5a134
commit dff153ff24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -596,7 +596,10 @@ static void moduleFreeKeyIterator(RedisModuleKey *key) {
serverAssert(key->iter != NULL);
switch (key->value->type) {
case OBJ_LIST: listTypeReleaseIterator(key->iter); break;
case OBJ_STREAM: zfree(key->iter); break;
case OBJ_STREAM:
streamIteratorStop(key->iter);
zfree(key->iter);
break;
default: serverAssert(0); /* No key->iter for other types. */
}
key->iter = NULL;
@ -5103,6 +5106,7 @@ int RM_StreamIteratorStop(RedisModuleKey *key) {
errno = EBADF;
return REDISMODULE_ERR;
}
streamIteratorStop(key->iter);
zfree(key->iter);
key->iter = NULL;
return REDISMODULE_OK;