Skip to content

Commit

Permalink
- Fixed bug #61388 (ReflectionObject:getProperties() issues invalid r…
Browse files Browse the repository at this point in the history
…eads

  when get_properties returns a hash table with (inaccessible) dynamic
  numeric properties).
  • Loading branch information
cataphract committed Mar 18, 2012
1 parent a369972 commit 773bedb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ext/reflection/php_reflection.c
Expand Up @@ -3832,6 +3832,13 @@ static int _adddynproperty(zval **pptr TSRMLS_DC, int num_args, va_list args, ze
zend_class_entry *ce = *va_arg(args, zend_class_entry**);
zval *retval = va_arg(args, zval*), member;

/* under some circumstances, the properties hash table may contain numeric
* properties (e.g. when casting from array). This is a WONT FIX bug, at
* least for the moment. Ignore these */
if (hash_key->nKeyLength == 0) {
return 0;
}

if (hash_key->arKey[0] == '\0') {
return 0; /* non public cannot be dynamic */
}
Expand Down
32 changes: 32 additions & 0 deletions ext/reflection/tests/bug61388.phpt
@@ -0,0 +1,32 @@
--TEST--
ReflectionObject:getProperties() issues invalid reads when it get_properties returns a hash table with (inaccessible) dynamic numeric properties
--FILE--
<?php
$x = new ArrayObject();
$x[0] = 'test string 2';
$x['test'] = 'test string 3';
$reflObj = new ReflectionObject($x);
print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC));

$x = (object)array("a", "oo" => "b");
$reflObj = new ReflectionObject($x);
print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC));
--EXPECT--
Array
(
[0] => ReflectionProperty Object
(
[name] => test
[class] => ArrayObject
)

)
Array
(
[0] => ReflectionProperty Object
(
[name] => oo
[class] => stdClass
)

)

0 comments on commit 773bedb

Please sign in to comment.