diff options
author | Rubin Xu <rubinxu@google.com> | 2020-11-24 22:20:56 +0000 |
---|---|---|
committer | Rubin Xu <rubinxu@google.com> | 2020-11-24 22:20:56 +0000 |
commit | 089e85f552ec92402d9fcd19d110b0c7521c4601 (patch) | |
tree | e083d942cea72fd7f960cf2ad25675ca97605339 | |
parent | 18600a1adbed5c4e462df69623b507b41d695bb7 (diff) | |
download | v8-089e85f552ec92402d9fcd19d110b0c7521c4601.tar.gz |
[parser] Fix off-by-one in parameter count check
Upstream: https://chromium-review.googlesource.com/c/1326029
Bug: 160610106
Test: atest proxy_resolver_v8_unittest
Change-Id: I547b1a0cb88094ed79bf6ffe034df7f8834be4d1
-rw-r--r-- | src/messages.h | 2 | ||||
-rw-r--r-- | src/parsing/parser-base.h | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/messages.h b/src/messages.h index bb595c2f..8845e53f 100644 --- a/src/messages.h +++ b/src/messages.h @@ -624,7 +624,7 @@ class ErrorUtils : public AllStatic { T(TooManyArguments, \ "Too many arguments in function call (only 65535 allowed)") \ T(TooManyParameters, \ - "Too many parameters in function definition (only 65535 allowed)") \ + "Too many parameters in function definition (only 65534 allowed)") \ T(TooManySpreads, \ "Literal containing too many nested spreads (up to 65534 allowed)") \ T(TooManyVariables, "Too many variables declared (only 4194303 allowed)") \ diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h index cf56c53a..dd7b2808 100644 --- a/src/parsing/parser-base.h +++ b/src/parsing/parser-base.h @@ -3595,7 +3595,8 @@ void ParserBase<Impl>::ParseFormalParameterList(FormalParametersT* parameters, if (peek() != Token::RPAREN) { while (true) { - if (parameters->arity > Code::kMaxArguments) { + // Add one since we're going to be adding a parameter. + if (parameters->arity + 1 > Code::kMaxArguments) { ReportMessage(MessageTemplate::kTooManyParameters); *ok = false; return; |