diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-28 09:23:53 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-28 09:23:53 +0100 |
| commit | 768bc7a0b8ee2a139111c8825e689a37f22ba0b7 (patch) | |
| tree | 3584c41a5874bc716b3adeda86d84842f770c36b | |
| parent | b93aefc1a78c65ffdad5ff772f1116aaa0434837 (diff) | |
| parent | ab3c94a54f173a8e5f8be2a2e552cb6a02177f42 (diff) | |
| download | php-git-768bc7a0b8ee2a139111c8825e689a37f22ba0b7.tar.gz | |
Merge branch 'PHP-7.3'
| -rw-r--r-- | Zend/tests/bug77530.phpt | 10 | ||||
| -rw-r--r-- | Zend/zend_compile.c | 9 |
2 files changed, 18 insertions, 1 deletions
diff --git a/Zend/tests/bug77530.phpt b/Zend/tests/bug77530.phpt new file mode 100644 index 0000000000..fdb2bac78b --- /dev/null +++ b/Zend/tests/bug77530.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #77530: PHP crashes when parsing '(2)::class' +--FILE-- +<?php + +echo (2)::class; + +?> +--EXPECTF-- +Fatal error: Illegal class name in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 6985e1bcaa..01c90559db 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1334,12 +1334,19 @@ static void zend_ensure_valid_class_fetch_type(uint32_t fetch_type) /* {{{ */ static zend_bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_ast *class_ast) /* {{{ */ { uint32_t fetch_type; + zval *class_name; if (class_ast->kind != ZEND_AST_ZVAL) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use ::class with dynamic class name"); } - fetch_type = zend_get_class_fetch_type(zend_ast_get_str(class_ast)); + class_name = zend_ast_get_zval(class_ast); + + if (Z_TYPE_P(class_name) != IS_STRING) { + zend_error_noreturn(E_COMPILE_ERROR, "Illegal class name"); + } + + fetch_type = zend_get_class_fetch_type(Z_STR_P(class_name)); zend_ensure_valid_class_fetch_type(fetch_type); switch (fetch_type) { |
