Check for recursion in expression arrow functions
Summary: Arrow functions can be infinitely nested: ``` a=>a=>a=>a... ``` and that can cause unbounded recursion in the parser, so add a `CHECK_RECURSION`. Reviewed By: neildhar Differential Revision: D38282995 fbshipit-source-id: afa264a3aee926eaed14ad35b5c25060182e1dc8
This commit is contained in:
Родитель
3bd34d14d2
Коммит
0231e25d77
|
@ -5177,6 +5177,9 @@ Optional<ESTree::Node *> JSParserImpl::parseArrowFunctionExpression(
|
|||
body = *optBody;
|
||||
expression = false;
|
||||
} else {
|
||||
// It's possible to recurse onto parseAssignmentExpression directly
|
||||
// and get stuck without a depth check if we don't have one here.
|
||||
CHECK_RECURSION;
|
||||
auto optConcise = parseAssignmentExpression(
|
||||
param.get(ParamIn),
|
||||
allowTypedArrowFunction,
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// RUN: (! echo "a" "=>b"{1..10000} | %hermesc -dump-ast - 2>&1 ) | %FileCheck -match-full-lines %s
|
||||
|
||||
// CHECK: {{.*}}: error: Too many nested expressions/statements/declarations
|
Загрузка…
Ссылка в новой задаче