]> granicus.if.org Git - php/commitdiff
Add AST export support for nullsafe operator
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 27 Jul 2020 08:17:19 +0000 (10:17 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 27 Jul 2020 08:20:02 +0000 (10:20 +0200)
Fixes oss-fuzz #24403 and variants.

Zend/tests/assert/expect_015.phpt
Zend/zend_ast.c

index 3414f52e1b2e90b6dbecf6eeb9ae48ad3b836425..ac67780730c524dec2f7231ca611787597b51364 100644 (file)
@@ -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();
         }
 
     }
index b1e564b5e90dd943b0091c554a54776e1a0ef9a1..f6e0b476e95659efb1e33485241ca347a50b65d1 100644 (file)
@@ -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);