Skip to content

Commit a3d2c33

Browse files
nielsdosGirgias
authored andcommitted
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 <[email protected]> Signed-off-by: George Peter Banyard <[email protected]>
1 parent c90c944 commit a3d2c33

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Zend/tests/gh10200.phpt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-10200 (zif_get_object_vars: Assertion `!(((__ht)->u.flags & (1<<2)) != 0)' failed.)
3+
--FILE--
4+
<?php
5+
6+
$xmlData = <<<EOF
7+
<?xml version="1.0" encoding="utf-8"?>
8+
<document>https://github.com/php/php-src/issues/10200 not encountered</document>
9+
EOF;
10+
11+
$xml = simplexml_load_string($xmlData);
12+
$output = get_object_vars($xml);
13+
var_dump($output);
14+
15+
?>
16+
--EXPECT--
17+
array(1) {
18+
[0]=>
19+
string(59) "https://github.com/php/php-src/issues/10200 not encountered"
20+
}

Zend/zend_builtin_functions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ ZEND_FUNCTION(get_object_vars)
764764
} else {
765765
array_init_size(return_value, zend_hash_num_elements(properties));
766766

767-
ZEND_HASH_MAP_FOREACH_KEY_VAL(properties, num_key, key, value) {
767+
ZEND_HASH_FOREACH_KEY_VAL(properties, num_key, key, value) {
768768
bool is_dynamic = 1;
769769
if (Z_TYPE_P(value) == IS_INDIRECT) {
770770
value = Z_INDIRECT_P(value);

0 commit comments

Comments
 (0)