зеркало из https://github.com/mozilla/gecko-dev.git
Bug 618572 - Assertion failure: *userbuf.ptr == c, at ../jsscan.cpp:349. r=brendan.
This commit is contained in:
Родитель
7e3ec98db1
Коммит
b88d0dd39f
|
@ -738,28 +738,49 @@ TokenStream::getXMLEntity()
|
|||
#endif /* JS_HAS_XML_SUPPORT */
|
||||
|
||||
/*
|
||||
* We have encountered a '\': check for a Unicode escape sequence after it,
|
||||
* returning the character code value if we found a Unicode escape sequence.
|
||||
* Otherwise, non-destructively return the original '\'.
|
||||
* We have encountered a '\': check for a Unicode escape sequence after it.
|
||||
* Return 'true' and the character code value (by value) if we found a
|
||||
* Unicode escape sequence. Otherwise, return 'false'. In both cases, do not
|
||||
* advance along the buffer.
|
||||
*/
|
||||
int32
|
||||
TokenStream::getUnicodeEscape()
|
||||
bool
|
||||
TokenStream::peekUnicodeEscape(int *result)
|
||||
{
|
||||
jschar cp[5];
|
||||
int32 c;
|
||||
|
||||
if (peekChars(5, cp) && cp[0] == 'u' &&
|
||||
JS7_ISHEX(cp[1]) && JS7_ISHEX(cp[2]) &&
|
||||
JS7_ISHEX(cp[3]) && JS7_ISHEX(cp[4]))
|
||||
{
|
||||
c = (((((JS7_UNHEX(cp[1]) << 4)
|
||||
*result = (((((JS7_UNHEX(cp[1]) << 4)
|
||||
+ JS7_UNHEX(cp[2])) << 4)
|
||||
+ JS7_UNHEX(cp[3])) << 4)
|
||||
+ JS7_UNHEX(cp[4]);
|
||||
skipChars(5);
|
||||
return c;
|
||||
return true;
|
||||
}
|
||||
return '\\';
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TokenStream::matchUnicodeEscapeIdStart(int32 *cp)
|
||||
{
|
||||
peekUnicodeEscape(cp);
|
||||
if (JS_ISIDSTART(*cp)) {
|
||||
skipChars(5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TokenStream::matchUnicodeEscapeIdent(int32 *cp)
|
||||
{
|
||||
peekUnicodeEscape(cp);
|
||||
if (JS_ISIDENT(*cp)) {
|
||||
skipChars(5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Token *
|
||||
|
@ -795,7 +816,7 @@ TokenStream::getTokenInternal()
|
|||
int c, qc;
|
||||
Token *tp;
|
||||
JSAtom *atom;
|
||||
JSBool hadUnicodeEscape;
|
||||
bool hadUnicodeEscape;
|
||||
const struct keyword *kw;
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
JSBool inTarget;
|
||||
|
@ -993,11 +1014,9 @@ TokenStream::getTokenInternal()
|
|||
* Look for an identifier.
|
||||
*/
|
||||
|
||||
hadUnicodeEscape = JS_FALSE;
|
||||
hadUnicodeEscape = false;
|
||||
if (JS_ISIDSTART(c) ||
|
||||
(c == '\\' &&
|
||||
(qc = getUnicodeEscape(),
|
||||
hadUnicodeEscape = JS_ISIDSTART(qc))))
|
||||
(c == '\\' && (hadUnicodeEscape = matchUnicodeEscapeIdStart(&qc))))
|
||||
{
|
||||
if (hadUnicodeEscape)
|
||||
c = qc;
|
||||
|
@ -1007,11 +1026,10 @@ TokenStream::getTokenInternal()
|
|||
goto error;
|
||||
c = getChar();
|
||||
if (c == '\\') {
|
||||
qc = getUnicodeEscape();
|
||||
if (!JS_ISIDENT(qc))
|
||||
if (!matchUnicodeEscapeIdent(&qc))
|
||||
break;
|
||||
c = qc;
|
||||
hadUnicodeEscape = JS_TRUE;
|
||||
hadUnicodeEscape = true;
|
||||
} else {
|
||||
if (!JS_ISIDENT(c))
|
||||
break;
|
||||
|
|
|
@ -462,7 +462,9 @@ class TokenStream
|
|||
void ungetChar(int32 c);
|
||||
void ungetCharIgnoreEOL(int32 c);
|
||||
Token *newToken(ptrdiff_t adjust);
|
||||
int32 getUnicodeEscape();
|
||||
bool peekUnicodeEscape(int32 *c);
|
||||
bool matchUnicodeEscapeIdStart(int32 *c);
|
||||
bool matchUnicodeEscapeIdent(int32 *c);
|
||||
JSBool peekChars(intN n, jschar *cp);
|
||||
JSBool getXMLEntity();
|
||||
jschar *findEOL();
|
||||
|
|
|
@ -56,5 +56,6 @@ script regress-610026.js
|
|||
script regress-609617.js
|
||||
script regress-617405-1.js
|
||||
script regress-617405-2.js
|
||||
script regress-618572.js
|
||||
skip-if(!xulRuntime.shell) script regress-618576.js # uses evalcx
|
||||
fails-if(!xulRuntime.shell) script regress-618652.js
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 618572;
|
||||
var summary = 'Do not assert when ungetting a Unicode char sequence';
|
||||
var actual = '';
|
||||
var expect = '';
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
test();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function test()
|
||||
{
|
||||
enterFunc ('test');
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
expect = 'SyntaxError: illegal character';
|
||||
|
||||
try
|
||||
{
|
||||
eval("var a\\u0346 = 3;");
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
actual = ex + '';
|
||||
}
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
Загрузка…
Ссылка в новой задаче