[GIT-PULLS] [php-src] PR #23127: Fix GH-23116 and GH-23117: stack overflow when normalizing a deeply nested document

[email protected] (lazerg)
Newsgroups php.git-pulls
Message-ID <4YtcwFyYvJ2mNdPWlh4AXFpdrCpLi15QN1fm4K7mZOM@main.internal.php.net>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.