Skip to content

Fix session save-handler argv leak on recursive rejection#22382

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:session-recursive-argv-leak
Open

Fix session save-handler argv leak on recursive rejection#22382
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:session-recursive-argv-leak

Conversation

@iliaal

@iliaal iliaal commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

ps_call_handler() returned on the recursive-call rejection branch before the argv cleanup loop, leaking one ref per owned argument. The read/write/destroy callers copy the session id and data into argv and rely on the function to release them, so a handler that re-enters session machinery (for example calling session_destroy() from within a write handler) leaks those strings. Folding the call into an else branch runs the cleanup unconditionally. Confirmed under USE_ZEND_ALLOC=0 valgrind: 64 bytes definitely lost, gone after the fix.

ps_call_handler() returned on the recursive-call rejection branch before
reaching the argv cleanup loop, leaking one ref per owned argument. The
read/write/destroy/validate_sid/update_timestamp callers copy the session
id and data into argv and rely on ps_call_handler() to release them, so a
handler that re-enters session machinery (for example calling
session_destroy() from within a write handler) leaks those strings. Fold
the handler call into an else branch so the cleanup loop always runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant