Skip to content

Commit ab3c94a

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 0da1308 + ef68cd3 commit ab3c94a

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PHP NEWS
77
(Dmitry)
88
. Fixed bug #77498 (Custom extension Segmentation fault when declare static
99
property). (Nikita)
10+
. Fixed bug #77530 (PHP crashes when parsing `(2)::class`). (Ekin)
1011

1112
- Mbstring:
1213
. Fixed bug #77514 (mb_ereg_replace() with trailing backslash adds null byte).

Zend/tests/bug77530.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #77530: PHP crashes when parsing '(2)::class'
3+
--FILE--
4+
<?php
5+
6+
echo (2)::class;
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Illegal class name in %s on line %d

Zend/zend_compile.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ static void zend_ensure_valid_class_fetch_type(uint32_t fetch_type) /* {{{ */
14801480
static zend_bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_ast *class_ast, zend_ast *name_ast, zend_bool constant) /* {{{ */
14811481
{
14821482
uint32_t fetch_type;
1483+
zval *class_name;
14831484

14841485
if (name_ast->kind != ZEND_AST_ZVAL) {
14851486
return 0;
@@ -1494,7 +1495,13 @@ static zend_bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_a
14941495
"Dynamic class names are not allowed in compile-time ::class fetch");
14951496
}
14961497

1497-
fetch_type = zend_get_class_fetch_type(zend_ast_get_str(class_ast));
1498+
class_name = zend_ast_get_zval(class_ast);
1499+
1500+
if (Z_TYPE_P(class_name) != IS_STRING) {
1501+
zend_error_noreturn(E_COMPILE_ERROR, "Illegal class name");
1502+
}
1503+
1504+
fetch_type = zend_get_class_fetch_type(Z_STR_P(class_name));
14981505
zend_ensure_valid_class_fetch_type(fetch_type);
14991506

15001507
switch (fetch_type) {

0 commit comments

Comments
 (0)