Bug 1089038 - Do not call peekToken after matchToken failed. r=Waldo

This commit is contained in:
Tooru Fujisawa 2014-10-30 02:21:00 +01:00
parent 81e1888082
commit 4f62dbcfd7

View File

@ -709,13 +709,10 @@ Parser<ParseHandler>::parse(JSObject *chain)
Node pn = statements(); Node pn = statements();
if (pn) { if (pn) {
bool matched; TokenKind tt;
if (!tokenStream.matchToken(&matched, TOK_EOF)) if (!tokenStream.getToken(&tt))
return null(); return null();
if (!matched) { if (tt != TOK_EOF) {
TokenKind tt;
if (!tokenStream.peekToken(&tt))
return null();
report(ParseError, false, null(), JSMSG_GARBAGE_AFTER_INPUT, report(ParseError, false, null(), JSMSG_GARBAGE_AFTER_INPUT,
"script", TokenKindToDesc(tt)); "script", TokenKindToDesc(tt));
return null(); return null();
@ -834,13 +831,10 @@ Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun, const AutoN
if (!pn) if (!pn)
return null(); return null();
bool matched; TokenKind tt;
if (!tokenStream.matchToken(&matched, TOK_EOF)) if (!tokenStream.getToken(&tt))
return null(); return null();
if (!matched) { if (tt != TOK_EOF) {
TokenKind tt;
if (!tokenStream.peekToken(&tt))
return null();
report(ParseError, false, null(), JSMSG_GARBAGE_AFTER_INPUT, report(ParseError, false, null(), JSMSG_GARBAGE_AFTER_INPUT,
"function body", TokenKindToDesc(tt)); "function body", TokenKindToDesc(tt));
return null(); return null();