Skip to content

Commit 920072d

Browse files
committed
- Fixed bug #61388 (ReflectionObject:getProperties() issues invalid reads
when get_properties returns a hash table with (inaccessible) dynamic numeric properties).
1 parent d870a41 commit 920072d

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

ext/reflection/php_reflection.c

+7
Original file line numberDiff line numberDiff line change
@@ -3832,6 +3832,13 @@ static int _adddynproperty(zval **pptr TSRMLS_DC, int num_args, va_list args, ze
38323832
zend_class_entry *ce = *va_arg(args, zend_class_entry**);
38333833
zval *retval = va_arg(args, zval*), member;
38343834

3835+
/* under some circumstances, the properties hash table may contain numeric
3836+
* properties (e.g. when casting from array). This is a WONT FIX bug, at
3837+
* least for the moment. Ignore these */
3838+
if (hash_key->nKeyLength == 0) {
3839+
return 0;
3840+
}
3841+
38353842
if (hash_key->arKey[0] == '\0') {
38363843
return 0; /* non public cannot be dynamic */
38373844
}

ext/reflection/tests/bug61388.phpt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
ReflectionObject:getProperties() issues invalid reads when it get_properties returns a hash table with (inaccessible) dynamic numeric properties
3+
--FILE--
4+
<?php
5+
$x = new ArrayObject();
6+
$x[0] = 'test string 2';
7+
$x['test'] = 'test string 3';
8+
$reflObj = new ReflectionObject($x);
9+
print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC));
10+
11+
$x = (object)array("a", "oo" => "b");
12+
$reflObj = new ReflectionObject($x);
13+
print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC));
14+
--EXPECT--
15+
Array
16+
(
17+
[0] => ReflectionProperty Object
18+
(
19+
[name] => test
20+
[class] => ArrayObject
21+
)
22+
23+
)
24+
Array
25+
(
26+
[0] => ReflectionProperty Object
27+
(
28+
[name] => oo
29+
[class] => stdClass
30+
)
31+
32+
)

0 commit comments

Comments
 (0)