@@ -440,7 +440,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
440
440
if (str_curr_p <= re_ctx_p->input_start_p )
441
441
{
442
442
JERRY_DDLOG (" match\n " );
443
- break ;
443
+ break ; /* tail merge */
444
444
}
445
445
446
446
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 */
452
452
if (lit_char_is_line_terminator (lit_utf8_peek_prev (str_curr_p)))
453
453
{
454
454
JERRY_DDLOG (" match\n " );
455
- break ;
455
+ break ; /* tail merge */
456
456
}
457
457
458
458
JERRY_DDLOG (" fail\n " );
@@ -1266,20 +1266,23 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
1266
1266
1267
1267
MEM_DEFINE_LOCAL_ARRAY (input_buffer_p, input_string_size, lit_utf8_byte_t );
1268
1268
1269
+ re_matcher_ctx_t re_ctx;
1270
+ lit_utf8_byte_t *input_curr_p = NULL ;
1269
1271
ssize_t sz = ecma_string_to_utf8_string (input_string_p, input_buffer_p, (ssize_t ) input_string_size);
1270
1272
JERRY_ASSERT (sz >= 0 );
1271
1273
1272
- lit_utf8_byte_t *input_curr_p = input_buffer_p;
1273
-
1274
- if (!input_string_size)
1274
+ if (input_string_size == 0u )
1275
1275
{
1276
1276
input_curr_p = (lit_utf8_byte_t *) lit_get_magic_string_utf8 (LIT_MAGIC_STRING__EMPTY);
1277
1277
}
1278
- lit_utf8_byte_t *input_end_p = input_buffer_p + input_string_size;
1278
+ else
1279
+ {
1280
+ input_curr_p = input_buffer_p;
1281
+ }
1279
1282
1280
- re_matcher_ctx_t re_ctx;
1281
- re_ctx.input_start_p = input_buffer_p ;
1282
- re_ctx.input_end_p = input_buffer_p + input_string_size ;
1283
+ re_ctx. input_start_p = input_curr_p ;
1284
+ const lit_utf8_byte_t *input_end_p = re_ctx.input_start_p + input_string_size ;
1285
+ re_ctx.input_end_p = input_end_p ;
1283
1286
1284
1287
/* 1. Read bytecode header and init regexp matcher context. */
1285
1288
re_ctx.flags = bc_p->flags ;
@@ -1390,7 +1393,8 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
1390
1393
ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
1391
1394
ecma_number_t *lastindex_num_p = ecma_alloc_number ();
1392
1395
1393
- if (sub_str_p)
1396
+ if (sub_str_p != NULL
1397
+ && input_buffer_p != NULL )
1394
1398
{
1395
1399
*lastindex_num_p = lit_utf8_string_length (input_buffer_p,
1396
1400
(lit_utf8_size_t ) (sub_str_p - input_buffer_p));
0 commit comments