File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change @@ -1334,12 +1334,19 @@ static void zend_ensure_valid_class_fetch_type(uint32_t fetch_type) /* {{{ */
1334
1334
static zend_bool zend_try_compile_const_expr_resolve_class_name (zval * zv , zend_ast * class_ast ) /* {{{ */
1335
1335
{
1336
1336
uint32_t fetch_type ;
1337
+ zval * class_name ;
1337
1338
1338
1339
if (class_ast -> kind != ZEND_AST_ZVAL ) {
1339
1340
zend_error_noreturn (E_COMPILE_ERROR , "Cannot use ::class with dynamic class name" );
1340
1341
}
1341
1342
1342
- fetch_type = zend_get_class_fetch_type (zend_ast_get_str (class_ast ));
1343
+ class_name = zend_ast_get_zval (class_ast );
1344
+
1345
+ if (Z_TYPE_P (class_name ) != IS_STRING ) {
1346
+ zend_error_noreturn (E_COMPILE_ERROR , "Illegal class name" );
1347
+ }
1348
+
1349
+ fetch_type = zend_get_class_fetch_type (Z_STR_P (class_name ));
1343
1350
zend_ensure_valid_class_fetch_type (fetch_type );
1344
1351
1345
1352
switch (fetch_type ) {
You can’t perform that action at this time.
0 commit comments