[php-src] PR #23127: Fix GH-23116 and GH-23117: stack overflow when normalizing a deeply nested document
| From: | lazerg | Date: | Sat, 08 Aug 2026 04:58:02 +0000 |
| Subject: | [php-src] PR #23127: Fix GH-23116 and GH-23117: stack overflow when normalizing a deeply nested document | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-37635@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23127
Author: lazerg
DOMNode::normalize() and Dom\Node::normalize() walk the tree by recursing
once per element child, so a deeply nested document exhausts the C stack and segfaults. Both now
check the stack limit on entry and throw an Error, the same way the XML serializer has
since GH-22570.
The throw is gated on EG(exception) because these functions return void: without it,
unwinding through a tree that is wide at the overflow depth throws once per node and chains the
Errors, which is quadratic.
Fixes #23116
Fixes #23117