Fix GH-10200: zif_get_object_vars: Assertion `!(((__ht)->u.flags & (1<<2)) != 0)' failed.

This occurs because the array of properties is a single element with an
integer key, not an associative array. Therefore it is a packed array
and thus the assumption the iteration macro makes is invalid.

This restores the behaviour of PHP<8.2.

Closes GH-10209

Co-authored-by: Deltik <deltik@gmx.com>

Signed-off-by: George Peter Banyard <girgias@php.net>
This commit is contained in:
Niels Dossche 2023-01-02 15:34:03 +01:00 committed by George Peter Banyard
parent 7b08fe9f2d
commit c2404915e0
3 changed files with 25 additions and 1 deletions

4
NEWS
View File

@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.2.2
- Core:
. Fixed bug GH-10200 (zif_get_object_vars:
Assertion `!(((__ht)->u.flags & (1<<2)) != 0)' failed). (nielsdos)
- FPM:
. Fixed bug #77106 (Missing separator in FPM FastCGI errors). (Jakub Zelenka)
. Fixed bug GH-9981 (FPM does not reset fastcgi.error_header).

20
Zend/tests/gh10200.phpt Normal file
View File

@ -0,0 +1,20 @@
--TEST--
GH-10200 (zif_get_object_vars: Assertion `!(((__ht)->u.flags & (1<<2)) != 0)' failed.)
--FILE--
<?php
$xmlData = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<document>https://github.com/php/php-src/issues/10200 not encountered</document>
EOF;
$xml = simplexml_load_string($xmlData);
$output = get_object_vars($xml);
var_dump($output);
?>
--EXPECT--
array(1) {
[0]=>
string(59) "https://github.com/php/php-src/issues/10200 not encountered"
}

View File

@ -760,7 +760,7 @@ ZEND_FUNCTION(get_object_vars)
} else {
array_init_size(return_value, zend_hash_num_elements(properties));
ZEND_HASH_MAP_FOREACH_KEY_VAL(properties, num_key, key, value) {
ZEND_HASH_FOREACH_KEY_VAL(properties, num_key, key, value) {
bool is_dynamic = 1;
if (Z_TYPE_P(value) == IS_INDIRECT) {
value = Z_INDIRECT_P(value);