Skip to content

Commit c240491

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 <deltik@gmx.com> Signed-off-by: George Peter Banyard <girgias@php.net>
1 parent 7b08fe9 commit c240491

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.2.2
44

5+
- Core:
6+
. Fixed bug GH-10200 (zif_get_object_vars:
7+
Assertion `!(((__ht)->u.flags & (1<<2)) != 0)' failed). (nielsdos)
8+
59
- FPM:
610
. Fixed bug #77106 (Missing separator in FPM FastCGI errors). (Jakub Zelenka)
711
. Fixed bug GH-9981 (FPM does not reset fastcgi.error_header).

Zend/tests/gh10200.phpt

Lines changed: 20 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ ZEND_FUNCTION(get_object_vars)
760760
} else {
761761
array_init_size(return_value, zend_hash_num_elements(properties));
762762

763-
ZEND_HASH_MAP_FOREACH_KEY_VAL(properties, num_key, key, value) {
763+
ZEND_HASH_FOREACH_KEY_VAL(properties, num_key, key, value) {
764764
bool is_dynamic = 1;
765765
if (Z_TYPE_P(value) == IS_INDIRECT) {
766766
value = Z_INDIRECT_P(value);

0 commit comments

Comments
 (0)