Fix leak and double free issues in datatype2 module test (#9102)

* Add missing call for RedisModule_DictDel in datatype2 test
* Fix memory leak in datatype2 test
This commit is contained in:
sundb 2021-06-18 02:45:21 +08:00 committed by GitHub
parent ada60d8003
commit eae0983d2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -220,6 +220,8 @@ void flushdbCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void
int i;
RedisModuleFlushInfo *fi = data;
RedisModule_AutoMemory(ctx);
if (sub == REDISMODULE_SUBEVENT_FLUSHDB_START) {
if (fi->dbnum != -1) {
MemPoolFreeDb(ctx, fi->dbnum);
@ -298,6 +300,7 @@ int MemFree_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc
int nokey;
struct MemBlock *mem = (struct MemBlock *)RedisModule_DictGet(mem_pool[RedisModule_GetSelectedDb(ctx)], argv[1], &nokey);
if (!nokey && mem) {
RedisModule_DictDel(mem_pool[RedisModule_GetSelectedDb(ctx)], argv[1], NULL);
MemBlockFree(mem);
o->used = 0;
o->size = 0;