Unverified Commit eae0983d authored by sundb's avatar sundb Committed by GitHub
Browse files

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