Fix double free in RDB load
Former-commit-id: 070c4818715b56645855abb72af47c846fc63027
This commit is contained in:
parent
4bf3388f4e
commit
08b353cd55
@ -2107,7 +2107,10 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof) {
|
|||||||
|
|
||||||
/* Read key */
|
/* Read key */
|
||||||
if (key != nullptr)
|
if (key != nullptr)
|
||||||
|
{
|
||||||
decrRefCount(key);
|
decrRefCount(key);
|
||||||
|
key = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if ((key = rdbLoadStringObject(rdb)) == NULL) goto eoferr;
|
if ((key = rdbLoadStringObject(rdb)) == NULL) goto eoferr;
|
||||||
/* Read value */
|
/* Read value */
|
||||||
@ -2119,7 +2122,9 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof) {
|
|||||||
* snapshot taken by the master may not be reflected on the slave. */
|
* snapshot taken by the master may not be reflected on the slave. */
|
||||||
if (listLength(g_pserver->masters) == 0 && !loading_aof && expiretime != -1 && expiretime < now) {
|
if (listLength(g_pserver->masters) == 0 && !loading_aof && expiretime != -1 && expiretime < now) {
|
||||||
decrRefCount(key);
|
decrRefCount(key);
|
||||||
|
key = nullptr;
|
||||||
decrRefCount(val);
|
decrRefCount(val);
|
||||||
|
val = nullptr;
|
||||||
} else {
|
} else {
|
||||||
/* Add the new object in the hash table */
|
/* Add the new object in the hash table */
|
||||||
int fInserted = dbMerge(db, key, val, rsi->fForceSetKey); // Note: dbMerge will incrRef
|
int fInserted = dbMerge(db, key, val, rsi->fForceSetKey); // Note: dbMerge will incrRef
|
||||||
@ -2136,6 +2141,7 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof) {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
decrRefCount(val);
|
decrRefCount(val);
|
||||||
|
val = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user