summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-08-31 14:50:31 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-08-31 14:50:40 +0200
commit1036fd2a70050a5955286e92852bbc560bb1fa78 (patch)
tree29fcab2493fb6ba7cc0983609d6d493f50e560d6
parentecd986c879cba35d71c2be144c8fe4c23a7aea72 (diff)
parent8bb2f406def958671e7719966a4c015dfe1e448b (diff)
downloadphp-git-1036fd2a70050a5955286e92852bbc560bb1fa78.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Check update constant failure in ReflectionClassConstant::__toString()
-rw-r--r--ext/reflection/php_reflection.c5
-rw-r--r--ext/reflection/tests/ReflectionClassConstant_toString_error.phpt18
2 files changed, 22 insertions, 1 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 016851e9e5..f5c2b0f63c 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 0000000000..54290e97aa
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Exception thrown while converting ReflectionClassConstant to string
+--FILE--
+<?php
+
+class B {
+ const X = self::UNKNOWN;
+}
+
+try {
+ echo new ReflectionClassConstant('B', 'X');
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Undefined constant self::UNKNOWN