Skip to content

Commit 1727d96

Browse files
beberleinikic
authored andcommitted
Fixed bug #80370: Segmentation fault reflecting attributes of dynamic property
Closes GH-6428.
1 parent 58d41b8 commit 1727d96

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #74558 (Can't rebind closure returned by Closure::fromCallable()).
77
(cmb)
88

9+
- Reflection:
10+
. Fixed bug #80370 (getAttributes segfault on dynamic properties). (Benjamin
11+
Eberlei)
12+
913
12 Nov 2020, PHP 8.0.0RC4
1014

1115
- Core:

ext/reflection/php_reflection.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5498,6 +5498,10 @@ ZEND_METHOD(ReflectionProperty, getAttributes)
54985498

54995499
GET_REFLECTION_OBJECT_PTR(ref);
55005500

5501+
if (ref->prop == NULL) {
5502+
RETURN_EMPTY_ARRAY();
5503+
}
5504+
55015505
reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU,
55025506
ref->prop->attributes, 0, ref->prop->ce, ZEND_ATTRIBUTE_TARGET_PROPERTY,
55035507
ref->prop->ce->type == ZEND_USER_CLASS ? ref->prop->ce->info.user.filename : NULL);

ext/reflection/tests/bug80370.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #80370: Segfault on ReflectionProperty::getAttributes of dynamic property
3+
--FILE--
4+
<?php
5+
class Foobar {
6+
7+
}
8+
9+
$foobar = new Foobar();
10+
$foobar->bar = 42;
11+
12+
$reflectionObject = new ReflectionObject($foobar);
13+
$reflectionProperty = $reflectionObject->getProperty('bar');
14+
var_dump($reflectionProperty->getAttributes());
15+
--EXPECT--
16+
array(0) {
17+
}

0 commit comments

Comments
 (0)