mmap-cache: LIST_REMOVE() *after* w->unused_prev

The LIST_REMOVE() macro always assigns NULL to w->unused_prev,
meaning every time this window was in last_unused, the remainder
of the unused list was lost to the ether.

Turns out there's been a memory leak in journald after all, this
code has been there since at least 2013...
This commit is contained in:
Vito Caputo 2021-11-25 07:05:06 -08:00 committed by Lennart Poettering
parent f1da1e7b5f
commit b82aca89a5

View File

@ -224,9 +224,9 @@ static void context_attach_window(Context *c, Window *w) {
if (w->in_unused) {
/* Used again? */
LIST_REMOVE(unused, c->cache->unused, w);
if (c->cache->last_unused == w)
c->cache->last_unused = w->unused_prev;
LIST_REMOVE(unused, c->cache->unused, w);
w->in_unused = false;
}