diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 016851e9e54..f5c2b0f63c0 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -557,7 +557,10 @@ static void _class_const_string(smart_str *str, char *name, zend_class_constant char *visibility = zend_visibility_string(Z_ACCESS_FLAGS(c->value)); const char *type; - zval_update_constant_ex(&c->value, c->ce); + if (zval_update_constant_ex(&c->value, c->ce) == FAILURE) { + return; + } + type = zend_zval_type_name(&c->value); if (Z_TYPE(c->value) == IS_ARRAY) { diff --git a/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt b/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt new file mode 100644 index 00000000000..54290e97aa3 --- /dev/null +++ b/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +Exception thrown while converting ReflectionClassConstant to string +--FILE-- +getMessage(), "\n"; +} + +?> +--EXPECT-- +Undefined constant self::UNKNOWN