[GIT-PULLS] [php-src] PR #23090: Fix GH-23088: Stack overflow when comparing deeply nested arrays

[email protected] (lazerg)
Newsgroups php.git-pulls
Message-ID <eh0MN9Jacg3zFEl6AYpb4wOZYzjETJYNKLEtmwTajKM@main.internal.php.net>
Pull Request: https://github.com/php/php-src/pull/23090
Author: lazerg

Comparing two deeply nested arrays with `==` recurses through `zend_compare` -> `zend_compare_arrays` -> `zend_compare_symbol_tables` -> `zend_hash_compare` once per nesting level, and nothing bounds that recursion. `zend_hash_compare()` only guards against cycles, so a non-cyclic array a few tens of thousands of levels deep runs the C stack out and the process dies with a segfault.

`zend_compare_symbol_tables()` now checks the stack limit before descending and throws an `Error` instead, the same way `zend_std_compare_objects()` already handles the object case.

Fixes GH-23088
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.