[php-src] PR #19318: Fix GH-19303: Unpacking empty packed array into uninitialized array causes assertion failure
| From: | nielsdos | Date: | Wed, 30 Jul 2025 17:00:22 +0000 |
| Subject: | [php-src] PR #19318: Fix GH-19303: Unpacking empty packed array into uninitialized array causes assertion failure | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-32714@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/19318
Author: nielsdos
Having an empty result array is not a problem, because zend_hash_extend() will initialize it. Except
it does not when the number of elements to add equals 0, which leaves the array uninitialized and
therefore does not set the packed flag, causing the assertion failure.
Technically, removing the assert would also work and save a check. On the other hand, this check
could also prevent some real work to be done and should be relatively cheap as we already have to
compute the sum anyway.