summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-07-27 10:17:19 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-07-27 10:20:02 +0200
commit3b5b288127db317b7a6fecf4fd00ae59a8e41da9 (patch)
tree380ab686a2f87292cb1b8f65881d6cee0c7790dd /Zend
parentd9f5c44d5fd067e3deaf2aa82d368084871c86dd (diff)
downloadphp-git-3b5b288127db317b7a6fecf4fd00ae59a8e41da9.tar.gz
Add AST export support for nullsafe operator
Fixes oss-fuzz #24403 and variants.
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/assert/expect_015.phpt4
-rw-r--r--Zend/zend_ast.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/Zend/tests/assert/expect_015.phpt b/Zend/tests/assert/expect_015.phpt
index 3414f52e1b..ac67780730 100644
--- a/Zend/tests/assert/expect_015.phpt
+++ b/Zend/tests/assert/expect_015.phpt
@@ -58,6 +58,8 @@ assert(0 && ($a = function &(array &$a, ?X $b = null) use ($c,&$d) : ?X {
$x = C::$z;
$x = ${$a . "_1"}::$z;
$x = C::${$z . "_1"};
+ $x?->y;
+ $x?->y();
}
}
}));
@@ -198,6 +200,8 @@ Warning: assert(): assert(0 && ($a = function &(array &$a, ?X $b = null) use($c,
$x = C::$z;
$x = ${$a . '_1'}::$z;
$x = C::${$z . '_1'};
+ $x?->y;
+ $x?->y();
}
}
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index b1e564b5e9..f6e0b476e9 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -1792,8 +1792,9 @@ simple_list:
smart_str_appendc(str, ']');
break;
case ZEND_AST_PROP:
+ case ZEND_AST_NULLSAFE_PROP:
zend_ast_export_ex(str, ast->child[0], 0, indent);
- smart_str_appends(str, "->");
+ smart_str_appends(str, ast->kind == ZEND_AST_NULLSAFE_PROP ? "?->" : "->");
zend_ast_export_var(str, ast->child[1], 0, indent);
break;
case ZEND_AST_STATIC_PROP:
@@ -2066,8 +2067,9 @@ simple_list:
/* 3 child nodes */
case ZEND_AST_METHOD_CALL:
+ case ZEND_AST_NULLSAFE_METHOD_CALL:
zend_ast_export_ex(str, ast->child[0], 0, indent);
- smart_str_appends(str, "->");
+ smart_str_appends(str, ast->kind == ZEND_AST_NULLSAFE_METHOD_CALL ? "?->" : "->");
zend_ast_export_var(str, ast->child[1], 0, indent);
smart_str_appendc(str, '(');
zend_ast_export_ex(str, ast->child[2], 0, indent);