Skip to content

Commit 53a8754

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix leak on consteval exception in ReflectionClass::__toString()
2 parents 1036fd2 + 1f6f9c7 commit 53a8754

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ext/reflection/php_reflection.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
383383
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, key, c) {
384384
_class_const_string(str, ZSTR_VAL(key), c, ZSTR_VAL(sub_indent));
385385
if (UNEXPECTED(EG(exception))) {
386+
zend_string_release(sub_indent);
386387
return;
387388
}
388389
} ZEND_HASH_FOREACH_END();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Constant evaluation exception during ReflectionClass::__toString()
3+
--FILE--
4+
<?php
5+
6+
class A {
7+
const C = self::UNKNOWN;
8+
}
9+
try {
10+
echo new ReflectionClass(A::class);
11+
} catch (Error $e) {
12+
echo $e->getMessage(), "\n";
13+
}
14+
15+
?>
16+
--EXPECT--
17+
Undefined constant self::UNKNOWN

0 commit comments

Comments
 (0)