Skip to content

Commit c7920ab

Browse files
committed
Fixed bug #77738 (Nullptr deref in zend_compile_expr)
1 parent 6814ba1 commit c7920ab

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 2019, PHP 7.2.17
44

55
- Core:
6+
. Fixed bug #77738 (Nullptr deref in zend_compile_expr). (Laruence)
67
. Fixed bug #77660 (Segmentation fault on break 2147483648). (Laruence)
78
. Fixed bug #77652 (Anonymous classes can lose their interface information).
89
(Nikita)

Zend/tests/bug77738.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
Bug #77738 (Nullptr deref in zend_compile_expr)
3+
--FILE--
4+
<?php
5+
__COMPILER_HALT_OFFSET__;
6+
; // <- important
7+
--EXPECTF--
8+
Warning: Use of undefined constant __COMPILER_HALT_OFFSET__ - assumed '__COMPILER_HALT_OFFSET__' %sbug77738.php on line %d

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7673,11 +7673,11 @@ void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */
76737673
if (zend_string_equals_literal(resolved_name, "__COMPILER_HALT_OFFSET__") || (name_ast->attr != ZEND_NAME_RELATIVE && zend_string_equals_literal(orig_name, "__COMPILER_HALT_OFFSET__"))) {
76747674
zend_ast *last = CG(ast);
76757675

7676-
while (last->kind == ZEND_AST_STMT_LIST) {
7676+
while (last && last->kind == ZEND_AST_STMT_LIST) {
76777677
zend_ast_list *list = zend_ast_get_list(last);
76787678
last = list->child[list->children-1];
76797679
}
7680-
if (last->kind == ZEND_AST_HALT_COMPILER) {
7680+
if (last && last->kind == ZEND_AST_HALT_COMPILER) {
76817681
result->op_type = IS_CONST;
76827682
ZVAL_LONG(&result->u.constant, Z_LVAL_P(zend_ast_get_zval(last->child[0])));
76837683
zend_string_release(resolved_name);

0 commit comments

Comments
 (0)