Reviewers: Kevin Millikin,

Description:
Limit the number of arguments in a function call to 32766.

Limit the number of arguments in a function call to 32766. This is identical
to the limit on the number of parameters to a function.



BUG=v8:1413
TEST=


Please review this at http://codereview.chromium.org/7054074/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/messages.js
  M src/parser.cc


Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index e390f7df957718561a848e55a429f02038bc3418..d60d4012c937a423690a47f934bea750d8390c6a 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -219,6 +219,7 @@ function FormatMessage(message) {
invalid_preparser_data: ["Invalid preparser data for function ", "%0"], strict_mode_with: ["Strict mode code may not include a with statement"], strict_catch_variable: ["Catch variable may not be eval or arguments in strict mode"], + too_many_arguments: ["Too many arguments in function call (only 32766 allowed)"], too_many_parameters: ["Too many parameters in function definition (only 32766 allowed)"], too_many_variables: ["Too many variables declared (only 32767 allowed)"], strict_param_name: ["Parameter name eval or arguments is not allowed in strict mode"],
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 41a8234c29a9f0859d406fd862502619970d56d2..cce337fb46d448b23c60f958b88d644f7cc851e0 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -3505,6 +3505,12 @@ ZoneList<Expression*>* Parser::ParseArguments(bool* ok) {
   while (!done) {
     Expression* argument = ParseAssignmentExpression(true, CHECK_OK);
     result->Add(argument);
+    if (result->length() > kMaxNumFunctionParameters) {
+      ReportMessageAt(scanner().location(), "too_many_arguments",
+                      Vector<const char*>::empty());
+      *ok = false;
+      return NULL;
+    }
     done = (peek() == Token::RPAREN);
     if (!done) Expect(Token::COMMA, CHECK_OK);
   }


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to