Skip to content

Commit 8bb2f40

Browse files
committed
Check update constant failure in ReflectionClassConstant::__toString()
1 parent 41e11a8 commit 8bb2f40

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ext/reflection/php_reflection.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,10 @@ static void _class_const_string(smart_str *str, char *name, zend_class_constant
547547
char *visibility = zend_visibility_string(Z_ACCESS_FLAGS(c->value));
548548
char *type;
549549

550-
zval_update_constant_ex(&c->value, c->ce);
550+
if (zval_update_constant_ex(&c->value, c->ce) == FAILURE) {
551+
return;
552+
}
553+
551554
type = zend_zval_type_name(&c->value);
552555

553556
if (Z_TYPE(c->value) == IS_ARRAY) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Exception thrown while converting ReflectionClassConstant to string
3+
--FILE--
4+
<?php
5+
6+
class B {
7+
const X = self::UNKNOWN;
8+
}
9+
10+
try {
11+
echo new ReflectionClassConstant('B', 'X');
12+
} catch (Error $e) {
13+
echo $e->getMessage(), "\n";
14+
}
15+
16+
?>
17+
--EXPECT--
18+
Undefined class constant 'self::UNKNOWN'

0 commit comments

Comments
 (0)