diff options
author | Benjamin Eberlei <kontakt@beberlei.de> | 2020-11-15 08:45:26 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-11-17 10:54:27 +0100 |
commit | 1727d96d0e1057ce140682b79d7f121dee0fc370 (patch) | |
tree | 0d5556885268e3be19d0e84094dbd48bf146a3f1 /ext/reflection | |
parent | 58d41b8c4f9e8006f6c136186ef4788b1cc901dc (diff) | |
download | php-git-1727d96d0e1057ce140682b79d7f121dee0fc370.tar.gz |
Fixed bug #80370: Segmentation fault reflecting attributes of dynamic property
Closes GH-6428.
Diffstat (limited to 'ext/reflection')
-rw-r--r-- | ext/reflection/php_reflection.c | 4 | ||||
-rw-r--r-- | ext/reflection/tests/bug80370.phpt | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 2be0ab98db..114b2c273f 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 0000000000..41d01c2e7e --- /dev/null +++ b/ext/reflection/tests/bug80370.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #80370: Segfault on ReflectionProperty::getAttributes of dynamic property +--FILE-- +<?php +class Foobar { + +} + +$foobar = new Foobar(); +$foobar->bar = 42; + +$reflectionObject = new ReflectionObject($foobar); +$reflectionProperty = $reflectionObject->getProperty('bar'); +var_dump($reflectionProperty->getAttributes()); +--EXPECT-- +array(0) { +} |