[php-src] PR #12831: Fix GH-12826: Weird pointers issue in nested loops
| From: | nielsdos | Date: | Wed, 29 Nov 2023 21:39:54 +0000 |
| Subject: | [php-src] PR #12831: Fix GH-12826: Weird pointers issue in nested loops | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-24371@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/12831
Author: nielsdos
This regressed in cd53ce838a.
The loop with
zend_hash_iterators_update hangs forever because iter_pos
can't advance to idx. This is because the
zend_hash_iterators_lower_pos upper bound is target->nNumUsed, but that
is set to source->nNumOfElements.
https://github.com/php/php-src/blob/e3de478f66b4d3e76aba92100cd77c4bbde07f78/Zend/zend_hash.c#L2419-L2422
https://github.com/php/php-src/blob/e3de478f66b4d3e76aba92100cd77c4bbde07f78/Zend/zend_hash.c#L2410
That means that if there are holes in the array, we still loop over all the buckets but the number
of bucket slots will not match. Fix it by changing the assignment.
I'm not entirely sure this is the whole story though.