mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
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:
parent
c90c944126
commit
a3d2c33b06
2 changed files with 21 additions and 1 deletions
20
Zend/tests/gh10200.phpt
Normal file
20
Zend/tests/gh10200.phpt
Normal 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"
|
||||||
|
}
|
|
@ -764,7 +764,7 @@ ZEND_FUNCTION(get_object_vars)
|
||||||
} else {
|
} else {
|
||||||
array_init_size(return_value, zend_hash_num_elements(properties));
|
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;
|
bool is_dynamic = 1;
|
||||||
if (Z_TYPE_P(value) == IS_INDIRECT) {
|
if (Z_TYPE_P(value) == IS_INDIRECT) {
|
||||||
value = Z_INDIRECT_P(value);
|
value = Z_INDIRECT_P(value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue