Skip to content

Commit 331da7e

Browse files
DanielEScherzernielsdos
authored andcommitted
Fix GH-16187: ReflectionClass::__toString() with packed properties hash table
Closes GH-16192.
1 parent 3d80d98 commit 331da7e

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ PHP NEWS
5151
. Fixed bug GH-16181 (phpdbg: exit in exception handler reports fatal error).
5252
(cmb)
5353

54+
- Reflection:
55+
. Fixed bug GH-16187 (Assertion failure in ext/reflection/php_reflection.c).
56+
(DanielEScherzer)
57+
5458
- SimpleXML:
5559
. Fixed bug GH-15837 (Segmentation fault in ext/simplexml/simplexml.c).
5660
(nielsdos)

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
477477

478478
count = 0;
479479
if (properties && zend_hash_num_elements(properties)) {
480-
ZEND_HASH_MAP_FOREACH_STR_KEY(properties, prop_name) {
480+
ZEND_HASH_FOREACH_STR_KEY(properties, prop_name) {
481481
if (prop_name && ZSTR_LEN(prop_name) && ZSTR_VAL(prop_name)[0]) { /* skip all private and protected properties */
482482
if (!zend_hash_exists(&ce->properties_info, prop_name)) {
483483
count++;

ext/reflection/tests/gh16187.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-16187 (ReflectionClass::__toString() with unpacked properties)
3+
--EXTENSIONS--
4+
simplexml
5+
--FILE--
6+
<?php
7+
$xml = '<form name="test"></form>';
8+
$simplexml = simplexml_load_string($xml);
9+
$reflector = new ReflectionObject($simplexml['name']);
10+
$reflector->__toString();
11+
?>
12+
DONE
13+
--EXPECT--
14+
DONE

0 commit comments

Comments
 (0)