From 23fe148d24abc537a6a33085e5db673a3249893b Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 15 Nov 2020 08:45:26 +0100 Subject: [PATCH] Fixed bug #80370: Segmentation fault reflecting attributes of dynamic property. --- ext/reflection/php_reflection.c | 4 ++++ ext/reflection/tests/bug80370.phpt | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 ext/reflection/tests/bug80370.phpt 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) { +}