@@ -612,30 +612,28 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
612
612
#if ENABLED (JERRY_ES2015 )
613
613
if (re_ctx_p -> flags & RE_FLAG_UNICODE )
614
614
{
615
- if (* re_ctx_p -> input_curr_p == LIT_CHAR_LEFT_BRACE )
615
+ if (re_ctx_p -> input_curr_p + 1 < re_ctx_p -> input_end_p
616
+ && re_ctx_p -> input_curr_p [0 ] == LIT_CHAR_LEFT_BRACE
617
+ && lit_char_is_hex_digit (re_ctx_p -> input_curr_p [1 ]))
616
618
{
617
- re_ctx_p -> input_curr_p ++ ;
619
+ lit_code_point_t cp = lit_char_hex_to_int (re_ctx_p -> input_curr_p [1 ]);
620
+ re_ctx_p -> input_curr_p += 2 ;
618
621
619
- if (re_ctx_p -> input_curr_p < re_ctx_p -> input_end_p && lit_char_is_hex_digit (* re_ctx_p -> input_curr_p ))
622
+ while (re_ctx_p -> input_curr_p < re_ctx_p -> input_end_p && lit_char_is_hex_digit (* re_ctx_p -> input_curr_p ))
620
623
{
621
- lit_code_point_t cp = lit_char_hex_to_int (* re_ctx_p -> input_curr_p ++ );
624
+ cp = cp * 16 + lit_char_hex_to_int (* re_ctx_p -> input_curr_p ++ );
622
625
623
- while ( re_ctx_p -> input_curr_p < re_ctx_p -> input_end_p && lit_char_is_hex_digit ( * re_ctx_p -> input_curr_p ))
626
+ if ( JERRY_UNLIKELY ( cp > LIT_UNICODE_CODE_POINT_MAX ))
624
627
{
625
- cp = cp * 16 + lit_char_hex_to_int (* re_ctx_p -> input_curr_p ++ );
626
-
627
- if (JERRY_UNLIKELY (cp > LIT_UNICODE_CODE_POINT_MAX ))
628
- {
629
- return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid unicode escape sequence" ));
630
- }
628
+ return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid unicode escape sequence" ));
631
629
}
630
+ }
632
631
633
- if (re_ctx_p -> input_curr_p < re_ctx_p -> input_end_p && * re_ctx_p -> input_curr_p == LIT_CHAR_RIGHT_BRACE )
634
- {
635
- re_ctx_p -> input_curr_p ++ ;
636
- re_ctx_p -> token .value = cp ;
637
- break ;
638
- }
632
+ if (re_ctx_p -> input_curr_p < re_ctx_p -> input_end_p && * re_ctx_p -> input_curr_p == LIT_CHAR_RIGHT_BRACE )
633
+ {
634
+ re_ctx_p -> input_curr_p ++ ;
635
+ re_ctx_p -> token .value = cp ;
636
+ break ;
639
637
}
640
638
}
641
639
@@ -867,7 +865,8 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
867
865
868
866
#if ENABLED (JERRY_ES2015 )
869
867
if (re_ctx_p -> flags & RE_FLAG_UNICODE
870
- && lit_is_code_point_utf16_high_surrogate (ch ))
868
+ && lit_is_code_point_utf16_high_surrogate (ch )
869
+ && re_ctx_p -> input_curr_p < re_ctx_p -> input_end_p )
871
870
{
872
871
const ecma_char_t next = lit_cesu8_peek_next (re_ctx_p -> input_curr_p );
873
872
if (lit_is_code_point_utf16_low_surrogate (next ))
0 commit comments