summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Einstein <rafi@redislabs.com>2021-10-31 15:59:48 +0200
committerOran Agra <oran@redislabs.com>2022-04-27 16:31:52 +0300
commit19c2b179c785b68c0dcfb0b3ae55509ff30cede1 (patch)
tree5285a76cedd6f72d5af4acf006b4e5fd855b8ee0
parent3ba7c6acbec7db07f3294a49f51ac9985ea21c84 (diff)
downloadredis-19c2b179c785b68c0dcfb0b3ae55509ff30cede1.tar.gz
Fix memory leak when there's a read error of module aux data from rdb. (#9705)
(cherry picked from commit 734cde7e3885bf4ba8120ca0cc07354851bb4db0)
-rw-r--r--src/rdb.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/rdb.c b/src/rdb.c
index 3a1eeb915..d9c45271e 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -2600,15 +2600,16 @@ int rdbLoadRio(rio *rdb, int rdbflags, rdbSaveInfo *rsi) {
io.ver = 2;
/* Call the rdb_load method of the module providing the 10 bit
* encoding version in the lower 10 bits of the module ID. */
- if (mt->aux_load(&io,moduleid&1023, when) != REDISMODULE_OK || io.error) {
- moduleTypeNameByID(name,moduleid);
- serverLog(LL_WARNING,"The RDB file contains module AUX data for the module type '%s', that the responsible module is not able to load. Check for modules log above for additional clues.", name);
- goto eoferr;
- }
+ int rc = mt->aux_load(&io,moduleid&1023, when);
if (io.ctx) {
moduleFreeContext(io.ctx);
zfree(io.ctx);
}
+ if (rc != REDISMODULE_OK || io.error) {
+ moduleTypeNameByID(name,moduleid);
+ serverLog(LL_WARNING,"The RDB file contains module AUX data for the module type '%s', that the responsible module is not able to load. Check for modules log above for additional clues.", name);
+ goto eoferr;
+ }
uint64_t eof = rdbLoadLen(rdb,NULL);
if (eof != RDB_MODULE_OPCODE_EOF) {
serverLog(LL_WARNING,"The RDB file contains module AUX data for the module '%s' that is not terminated by the proper module value EOF marker", name);