Revision: 5811
Author: [email protected]
Date: Thu Nov 11 02:18:48 2010
Log: Fix Chromium bug 62639.
Add missing failure check after expecting an identifier in preparser.
This allowed code to use the non-existing literal.
Review URL: http://codereview.chromium.org/4800001
http://code.google.com/p/v8/source/detail?r=5811
Modified:
/branches/bleeding_edge/src/preparser.h
/branches/bleeding_edge/test/cctest/test-parsing.cc
=======================================
--- /branches/bleeding_edge/src/preparser.h Fri Nov 5 06:33:40 2010
+++ /branches/bleeding_edge/src/preparser.h Thu Nov 11 02:18:48 2010
@@ -1370,6 +1370,7 @@
template <typename Scanner, typename Log>
Identifier PreParser<Scanner, Log>::ParseIdentifier(bool* ok) {
Expect(i::Token::IDENTIFIER, ok);
+ if (!*ok) return kUnknownIdentifier;
return GetIdentifierSymbol();
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-parsing.cc Fri Nov 5 06:33:40
2010
+++ /branches/bleeding_edge/test/cctest/test-parsing.cc Thu Nov 11 02:18:48
2010
@@ -270,3 +270,26 @@
CHECK(!data.has_error());
}
}
+
+
+TEST(RegressChromium62639) {
+ int marker;
+ i::StackGuard::SetStackLimit(
+ reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
+
+ // Ensure that the source code is so big that it triggers preparsing.
+ char buffer[4096];
+ const char* program_template = "var x = '%01024d'; // filler\n"
+ "escape: function() {}";
+ // Fails parsing expecting an identifier after "function".
+ // Before fix, didn't check *ok after Expect(Token::Identifier, ok),
+ // and then used the invalid currently scanned literal. This always
+ // failed in debug mode, and sometimes crashed in release mode.
+
+ snprintf(buffer, sizeof(buffer), program_template, 0);
+ unibrow::Utf8InputBuffer<256> stream(buffer, strlen(buffer));
+ i::ScriptDataImpl* data =
+ i::ParserApi::PreParse(i::Handle<i::String>::null(), &stream, NULL);
+ CHECK(data->HasError());
+ delete data;
+}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev