Fix parsing of comments which contain zero character.
JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
@@ -1155,6 +1155,12 @@ lexer_parse_regexp (void)
|
||||
return result;
|
||||
} /* lexer_parse_regexp */
|
||||
|
||||
/**
|
||||
* Parse a comment
|
||||
*
|
||||
* @return true if newline was met during parsing
|
||||
* false - otherwise
|
||||
*/
|
||||
static bool
|
||||
lexer_parse_comment (void)
|
||||
{
|
||||
@@ -1170,7 +1176,7 @@ lexer_parse_comment (void)
|
||||
consume_char ();
|
||||
consume_char ();
|
||||
|
||||
while (true)
|
||||
while (!lit_utf8_iterator_is_eos (&src_iter))
|
||||
{
|
||||
c = LA (0);
|
||||
|
||||
@@ -1180,10 +1186,6 @@ lexer_parse_comment (void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (c == LIT_CHAR_NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1199,14 +1201,17 @@ lexer_parse_comment (void)
|
||||
{
|
||||
was_newlines = true;
|
||||
}
|
||||
else if (c == LIT_CHAR_NULL)
|
||||
{
|
||||
PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, "Unclosed multiline comment", lit_utf8_iterator_get_pos (&src_iter));
|
||||
}
|
||||
}
|
||||
|
||||
consume_char ();
|
||||
}
|
||||
|
||||
if (multiline)
|
||||
{
|
||||
PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, "Unclosed multiline comment", lit_utf8_iterator_get_pos (&src_iter));
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* lexer_parse_comment */
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
try {
|
||||
eval("/*var " + String.fromCharCode(0) + "xx = 1*/");
|
||||
}
|
||||
catch (e) {
|
||||
assert (false);
|
||||
}
|
||||
Reference in New Issue
Block a user