Fix memory leak in RDB load

Former-commit-id: a424194f42e61a324489464a0fed14837b8191e4
This commit is contained in:
John Sully 2020-02-16 18:41:29 -05:00
parent 535925abea
commit ed1b2ce2c8

View File

@ -1676,9 +1676,15 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, robj *key, uint64_t mvcc_tstamp) {
== NULL) return NULL; == NULL) return NULL;
if (rdbtype == RDB_TYPE_ZSET_2) { if (rdbtype == RDB_TYPE_ZSET_2) {
if (rdbLoadBinaryDoubleValue(rdb,&score) == -1) return NULL; if (rdbLoadBinaryDoubleValue(rdb,&score) == -1) {
sdsfree(sdsele);
return NULL;
}
} else { } else {
if (rdbLoadDoubleValue(rdb,&score) == -1) return NULL; if (rdbLoadDoubleValue(rdb,&score) == -1) {
sdsfree(sdsele);
return NULL;
}
} }
/* Don't care about integer-encoded strings. */ /* Don't care about integer-encoded strings. */
@ -2487,6 +2493,8 @@ int rdbLoadRio(rio *rdb, int rdbflags, rdbSaveInfo *rsi) {
decrRefCount(val); decrRefCount(val);
val = nullptr; val = nullptr;
} }
decrRefCount(key);
key = nullptr;
} }
if (g_pserver->key_load_delay) if (g_pserver->key_load_delay)
usleep(g_pserver->key_load_delay); usleep(g_pserver->key_load_delay);