summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c1
-rw-r--r--ext/reflection/tests/ReflectionClass_toString_004.phpt17
2 files changed, 18 insertions, 0 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index f5c2b0f63c..11b834503b 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -383,6 +383,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, key, c) {
_class_const_string(str, ZSTR_VAL(key), c, ZSTR_VAL(sub_indent));
if (UNEXPECTED(EG(exception))) {
+ zend_string_release(sub_indent);
return;
}
} ZEND_HASH_FOREACH_END();
diff --git a/ext/reflection/tests/ReflectionClass_toString_004.phpt b/ext/reflection/tests/ReflectionClass_toString_004.phpt
new file mode 100644
index 0000000000..0eecb3c8a3
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_toString_004.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Constant evaluation exception during ReflectionClass::__toString()
+--FILE--
+<?php
+
+class A {
+ const C = self::UNKNOWN;
+}
+try {
+ echo new ReflectionClass(A::class);
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Undefined constant self::UNKNOWN