From 2bf2cede8933586bb5be2fd77af650a23fcc936e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 21 Sep 2020 10:50:29 +0200 Subject: [PATCH] Initialize attributes for internal functions Fixes a crash in Symfony SecurityBundle tests. --- .../029_reflect_internal_symbols.phpt | 32 +++++++++++++++++++ Zend/zend_API.c | 1 + 2 files changed, 33 insertions(+) create mode 100644 Zend/tests/attributes/029_reflect_internal_symbols.phpt diff --git a/Zend/tests/attributes/029_reflect_internal_symbols.phpt b/Zend/tests/attributes/029_reflect_internal_symbols.phpt new file mode 100644 index 00000000000..d4dc29a0bb9 --- /dev/null +++ b/Zend/tests/attributes/029_reflect_internal_symbols.phpt @@ -0,0 +1,32 @@ +--TEST-- +Reflect attributes on different kinds of internal symbols +--FILE-- +getAttributes()); + +$rc = new ReflectionClass('DateTime'); +var_dump($rc->getAttributes()); + +$rm = $rc->getMethod('__construct'); +var_dump($rm->getAttributes()); + +$rcc = $rc->getReflectionConstant('ATOM'); +var_dump($rcc->getAttributes()); + +$rp = new ReflectionProperty('Exception', 'message'); +var_dump($rp->getAttributes()); + +?> +--EXPECT-- +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} diff --git a/Zend/zend_API.c b/Zend/zend_API.c index ee0e361ed99..6e89da89bbd 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2325,6 +2325,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend internal_function->function_name = zend_string_init_interned(ptr->fname, fname_len, 1); internal_function->scope = scope; internal_function->prototype = NULL; + internal_function->attributes = NULL; if (ptr->flags) { if (!(ptr->flags & ZEND_ACC_PPP_MASK)) { if (ptr->flags != ZEND_ACC_DEPRECATED && scope) {