From 3b5b288127db317b7a6fecf4fd00ae59a8e41da9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 27 Jul 2020 10:17:19 +0200 Subject: Add AST export support for nullsafe operator Fixes oss-fuzz #24403 and variants. --- Zend/tests/assert/expect_015.phpt | 4 ++++ Zend/zend_ast.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'Zend') 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); -- cgit v1.2.1