com php-src: Add AST export support for nullsafe operator: Zend/tests/assert/expect_015.phpt Zend/zend_ast .c

From: Date: Mon, 27 Jul 2020 08:20:02 +0000
Subject: com php-src: Add AST export support for nullsafe operator: Zend/tests/assert/expect_015.phpt Zend/zend_ast .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-112366@lists.php.net to get a copy of this message
Commit: 3b5b288127db317b7a6fecf4fd00ae59a8e41da9 Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 27 Jul 2020 10:17:19 +0200 Parents: d9f5c44d5fd067e3deaf2aa82d368084871c86dd Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3b5b288127db317b7a6fecf4fd00ae59a8e41da9 Log: Add AST export support for nullsafe operator Fixes oss-fuzz #24403 and variants. Bugs: https://bugs.php.net/24403 Changed paths: M Zend/tests/assert/expect_015.phpt M Zend/zend_ast.c Diff: 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);

« previous php.cvs (#112366) next »