Fix bytecode emitting for invalid regexp literals (#4422)

This patch fixes #4408.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2021-01-07 17:19:52 +01:00
committed by GitHub
parent 7972386412
commit 979a0c7826
3 changed files with 30 additions and 4 deletions
+3 -3
View File
@@ -2178,16 +2178,16 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
{
lexer_construct_regexp_object (context_p, false);
uint16_t literal_index = (uint16_t) (context_p->literal_count - 1);
#if ENABLED (JERRY_ESNEXT)
if (JERRY_UNLIKELY (context_p->lit_object.literal_p->type == LEXER_STRING_LITERAL))
{
parser_emit_cbc_ext_literal (context_p, CBC_EXT_THROW_SYNTAX_ERROR, literal_index);
parser_emit_cbc_ext_literal (context_p, CBC_EXT_THROW_SYNTAX_ERROR, context_p->lit_object.index);
break;
}
#endif /* ENABLED (JERRY_ESNEXT) */
uint16_t literal_index = (uint16_t) (context_p->literal_count - 1);
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
{
context_p->last_cbc_opcode = CBC_PUSH_TWO_LITERALS;