Skip to content

Commit 8a9df88

Browse files
committed
Fix null-pointer deref in if stmt printing
Fixes OSS-Fuzz #17721.
1 parent d2331cc commit 8a9df88

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Zend/tests/assert/expect_015.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ assert(0 && ($a = function () {
140140
if ($a) {
141141
} elseif ($b) {
142142
}
143+
if ($a); else;
143144
}));
144145

145146
?>
@@ -292,4 +293,7 @@ Warning: assert(): assert(0 && ($a = function () {
292293
if ($a) {
293294
} elseif ($b) {
294295
}
296+
if ($a) {
297+
} else {
298+
}
295299
})) failed in %sexpect_015.php on line %d

Zend/zend_ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ static void zend_ast_export_if_stmt(smart_str *str, zend_ast_list *list, int ind
894894
} else {
895895
zend_ast_export_indent(str, indent);
896896
smart_str_appends(str, "} else ");
897-
if (ast->child[1]->kind == ZEND_AST_IF) {
897+
if (ast->child[1] && ast->child[1]->kind == ZEND_AST_IF) {
898898
list = (zend_ast_list*)ast->child[1];
899899
goto tail_call;
900900
} else {

0 commit comments

Comments
 (0)