Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Unified Diff: src/parser.cc

Issue 12613007: Harden Function()'s parsing of function literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler.cc ('k') | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 62b633ea2807f4edbfed4d6147196058f3745ec9..2b2cf65d1f2fc5b4ec61474fb227fc9ee98e0e5a 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -656,6 +656,16 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
CheckConflictingVarDeclarations(top_scope_, &ok);
}
+ if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
+ if (body->length() != 1 ||
+ !body->at(0)->IsExpressionStatement() ||
+ !body->at(0)->AsExpressionStatement()->
+ expression()->IsFunctionLiteral()) {
+ ReportMessage("unable_to_parse", Vector<const char*>::empty());
+ ok = false;
+ }
+ }
+
if (ok) {
result = factory()->NewFunctionLiteral(
no_name,
« no previous file with comments | « src/compiler.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698