mirror of
https://github.com/redis/redis.git
synced 2026-05-28 04:02:46 -04:00
Fix memory leak in lpBatchInsert() (#14866)
Some checks are pending
CI / test-ubuntu-latest (push) Waiting to run
CI / test-sanitizer-address (push) Waiting to run
CI / build-debian-old (push) Waiting to run
CI / build-macos-latest (push) Waiting to run
CI / build-32bit (push) Waiting to run
CI / build-libc-malloc (push) Waiting to run
CI / build-centos-jemalloc (push) Waiting to run
CI / build-old-chain-jemalloc (push) Waiting to run
Codecov / code-coverage (push) Waiting to run
External Server Tests / test-external-standalone (push) Waiting to run
External Server Tests / test-external-cluster (push) Waiting to run
External Server Tests / test-external-nodebug (push) Waiting to run
Spellcheck / Spellcheck (push) Waiting to run
Some checks are pending
CI / test-ubuntu-latest (push) Waiting to run
CI / test-sanitizer-address (push) Waiting to run
CI / build-debian-old (push) Waiting to run
CI / build-macos-latest (push) Waiting to run
CI / build-32bit (push) Waiting to run
CI / build-libc-malloc (push) Waiting to run
CI / build-centos-jemalloc (push) Waiting to run
CI / build-old-chain-jemalloc (push) Waiting to run
Codecov / code-coverage (push) Waiting to run
External Server Tests / test-external-standalone (push) Waiting to run
External Server Tests / test-external-cluster (push) Waiting to run
External Server Tests / test-external-nodebug (push) Waiting to run
Spellcheck / Spellcheck (push) Waiting to run
This commit is contained in:
parent
3dc246cd53
commit
f2adcdedbc
1 changed files with 8 additions and 2 deletions
|
|
@ -1208,7 +1208,10 @@ unsigned char *lpBatchInsert(unsigned char *lp, unsigned char *p, int where,
|
|||
|
||||
uint64_t old_listpack_bytes = lpGetTotalBytes(lp);
|
||||
uint64_t new_listpack_bytes = old_listpack_bytes + addedlen;
|
||||
if (new_listpack_bytes > UINT32_MAX) return NULL;
|
||||
if (new_listpack_bytes > UINT32_MAX) {
|
||||
if (enc != tmp) lp_free(enc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Store the offset of the element 'p', so that we can obtain its
|
||||
* address again after a reallocation. */
|
||||
|
|
@ -1218,7 +1221,10 @@ unsigned char *lpBatchInsert(unsigned char *lp, unsigned char *p, int where,
|
|||
/* Realloc before: we need more room. */
|
||||
if (new_listpack_bytes > old_listpack_bytes &&
|
||||
new_listpack_bytes > lp_malloc_size(lp)) {
|
||||
if ((lp = lp_realloc(lp,new_listpack_bytes)) == NULL) return NULL;
|
||||
if ((lp = lp_realloc(lp,new_listpack_bytes)) == NULL) {
|
||||
if (enc != tmp) lp_free(enc);
|
||||
return NULL;
|
||||
}
|
||||
dst = lp + poff;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue