Files
Dmitry Rantovov b91b13899f [NETSH] Compare the stack entry against the tail, not the head twice (#9473)
RemoveContextFromStack tests pStackEntry == pContextStackHead twice
in the same condition, so the first branch takes every entry that happens
to be the head, not only the one that is head and tail at once.
The branch below it, the one that relinks pStackEntry->pNext->pPrev and
moves the head forward, is then unreachable. Removing the head of a stack
that has more than one entry sets both head and tail to NULL and frees
only that entry, so the remaining entries are lost and leaked.

The body of the first branch is what says which test was meant:
it clears both ends, and that is only correct for the single element case.

Compare the second test against pContextStackTail.

I found this by reading, not by hitting it in a running netsh session,
so I have not confirmed the leak on a live context stack.

Reviewed-by: Whindmar Saksit <whindsaks@proton.me>
Reviewed-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Reviewed-by: Eric Kohl <eric.kohl@reactos.org>
Signed-off-by: Dmitry Rantovov <rantovov5@gmail.com>
2026-09-05 19:56:13 +03:00
..
2026-03-18 17:29:12 +02:00