[php-src] PR #22493: Fix GH-22480: phpdbg use-after-free re-watching a watched variable
| From: | iliaal | Date: | Sat, 27 Jun 2026 21:38:47 +0000 |
| Subject: | [php-src] PR #22493: Fix GH-22480: phpdbg use-after-free re-watching a watched variable | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36703@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22493
Author: iliaal
Fixes #22480
phpdbg_add_watch_element() frees the passed element and returns the existing one when
the variable is already watched, but several callers kept using the freed pointer, so re-watching a
variable was a use-after-free. The two reported derefs are not the whole bug: with only the proposed
two-line capture, w a $a typed twice still crashes, relocated to a later
interned-string read. This reports the duplicate back through the parse callback so the wrapper
registers nothing, and rejects a recursive watch's hashtable element that collides with an
existing watch, at creation and recreation, instead of freeing a still-referenced one.