mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 14:51:27 +02:00
BUG/MEDIUM: lru: fix possible memory leak when ->free() is used
Commit 7810ad7 ("BUG/MAJOR: lru: fix unconditional call to free due to unexpected semi-colon") was not enough, it happens that the free() is not performed at the right place because if the evicted node is recycled, we must also release its data before it gets overwritten. No backport is needed.
This commit is contained in:
parent
ce7b4def74
commit
57b8a53f03
@ -127,11 +127,11 @@ struct lru64 *lru64_get(unsigned long long key, struct lru64_head *lru,
|
||||
/* not locked */
|
||||
LIST_DEL(&old->lru);
|
||||
__eb64_delete(&old->node);
|
||||
if (old->data && old->free)
|
||||
old->free(old->data);
|
||||
if (!lru->spare)
|
||||
lru->spare = old;
|
||||
else {
|
||||
if (old->data && old->free)
|
||||
old->free(old->data);
|
||||
free(old);
|
||||
}
|
||||
lru->cache_usage--;
|
||||
|
Loading…
x
Reference in New Issue
Block a user