Skip to content

Commit

Permalink
Fix memory leak when loading slot migrations states fails (valkey-io#658
Browse files Browse the repository at this point in the history
)

When we goto eoferr, we need to release the auxkey and auxval,
this is a cleanup, also explicitly check that decoder return
value is C_ERR.

Introduced in valkey-io#586.

Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin authored Jun 18, 2024
1 parent b33f932 commit a2cc2fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,11 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin
if (de != NULL) {
handled = 1;
rdbAuxFieldCodec *codec = (rdbAuxFieldCodec *)dictGetVal(de);
if (codec->decoder(rdbflags, auxval->ptr) < 0) goto eoferr;
if (codec->decoder(rdbflags, auxval->ptr) == C_ERR) {
decrRefCount(auxkey);
decrRefCount(auxval);
goto eoferr;
}
}
}

Expand Down

0 comments on commit a2cc2fe

Please sign in to comment.