summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-08-31 15:10:34 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-08-31 15:10:53 +0200
commit53a87547c8545aa26330ae2ba306364a73d0b93d (patch)
treeff8845c19998ca31bc3996a8b04aa3d02779c63b /ext/reflection
parent1036fd2a70050a5955286e92852bbc560bb1fa78 (diff)
parent1f6f9c70cb4e82ca9fbbf3153173e3d73a0f9170 (diff)
downloadphp-git-53a87547c8545aa26330ae2ba306364a73d0b93d.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Fix leak on consteval exception in ReflectionClass::__toString()
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