@@ -440,7 +440,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
440440 if (str_curr_p <= re_ctx_p->input_start_p )
441441 {
442442 JERRY_DDLOG (" match\n " );
443- break ;
443+ break ; /* tail merge */
444444 }
445445
446446 if (!(re_ctx_p->flags & RE_FLAG_MULTILINE))
@@ -452,7 +452,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
452452 if (lit_char_is_line_terminator (lit_utf8_peek_prev (str_curr_p)))
453453 {
454454 JERRY_DDLOG (" match\n " );
455- break ;
455+ break ; /* tail merge */
456456 }
457457
458458 JERRY_DDLOG (" fail\n " );
@@ -1261,20 +1261,23 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
12611261
12621262 MEM_DEFINE_LOCAL_ARRAY (input_buffer_p, input_string_size, lit_utf8_byte_t );
12631263
1264+ re_matcher_ctx_t re_ctx;
1265+ lit_utf8_byte_t *input_curr_p = NULL ;
12641266 ssize_t sz = ecma_string_to_utf8_string (input_string_p, input_buffer_p, (ssize_t ) input_string_size);
12651267 JERRY_ASSERT (sz >= 0 );
12661268
1267- lit_utf8_byte_t *input_curr_p = input_buffer_p;
1268-
1269- if (!input_string_size)
1269+ if (input_string_size == 0u )
12701270 {
12711271 input_curr_p = (lit_utf8_byte_t *) lit_get_magic_string_utf8 (LIT_MAGIC_STRING__EMPTY);
12721272 }
1273- lit_utf8_byte_t *input_end_p = input_buffer_p + input_string_size;
1273+ else
1274+ {
1275+ input_curr_p = input_buffer_p;
1276+ }
12741277
1275- re_matcher_ctx_t re_ctx;
1276- re_ctx.input_start_p = input_buffer_p ;
1277- re_ctx.input_end_p = input_buffer_p + input_string_size ;
1278+ re_ctx. input_start_p = input_curr_p ;
1279+ const lit_utf8_byte_t *input_end_p = re_ctx.input_start_p + input_string_size ;
1280+ re_ctx.input_end_p = input_end_p ;
12781281
12791282 /* 1. Read bytecode header and init regexp matcher context. */
12801283 re_ctx.flags = bc_p->flags ;
@@ -1385,7 +1388,8 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
13851388 ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
13861389 ecma_number_t *lastindex_num_p = ecma_alloc_number ();
13871390
1388- if (sub_str_p)
1391+ if (sub_str_p != NULL
1392+ && input_buffer_p != NULL )
13891393 {
13901394 *lastindex_num_p = lit_utf8_string_length (input_buffer_p,
13911395 (lit_utf8_size_t ) (sub_str_p - input_buffer_p));
0 commit comments