diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 2be0ab98db656..114b2c273ff19 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -5498,6 +5498,10 @@ ZEND_METHOD(ReflectionProperty, getAttributes) GET_REFLECTION_OBJECT_PTR(ref); + if (ref->prop == NULL) { + RETURN_EMPTY_ARRAY(); + } + reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU, ref->prop->attributes, 0, ref->prop->ce, ZEND_ATTRIBUTE_TARGET_PROPERTY, ref->prop->ce->type == ZEND_USER_CLASS ? ref->prop->ce->info.user.filename : NULL); diff --git a/ext/reflection/tests/bug80370.phpt b/ext/reflection/tests/bug80370.phpt new file mode 100644 index 0000000000000..41d01c2e7e38b --- /dev/null +++ b/ext/reflection/tests/bug80370.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #80370: Segfault on ReflectionProperty::getAttributes of dynamic property +--FILE-- +bar = 42; + +$reflectionObject = new ReflectionObject($foobar); +$reflectionProperty = $reflectionObject->getProperty('bar'); +var_dump($reflectionProperty->getAttributes()); +--EXPECT-- +array(0) { +}