Skip to content

Commit

Permalink
Fix memory leak when loading slot migrations states fails
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 committed Jun 17, 2024
1 parent 5a51bf5 commit d7a7e9a
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 d7a7e9a

Please sign in to comment.