Fix memory leak when loading slot migrations states fails (#658)

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 #586.

Signed-off-by: Binbin <binloveplay1314@qq.com>
This commit is contained in:
Binbin 2024-06-18 12:18:57 +08:00 committed by GitHub
parent b33f932c56
commit a2cc2fe26d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}
}
}