@@ -1249,7 +1249,7 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
12491249 int32_t index = 0 ;
12501250 ecma_length_t input_str_len ;
12511251
1252- input_str_len = lit_utf8_string_length ( input_buffer_p , input_buffer_size );
1252+ input_str_len = ecma_string_get_length ( input_string_p );
12531253
12541254 if (input_buffer_p && (re_ctx .flags & RE_FLAG_GLOBAL ))
12551255 {
@@ -1264,9 +1264,16 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
12641264 && index <= (int32_t ) input_str_len
12651265 && index > 0 )
12661266 {
1267- for ( int i = 0 ; i < index ; i ++ )
1267+ if ( input_str_len == input_buffer_size )
12681268 {
1269- lit_utf8_incr (& input_curr_p );
1269+ input_curr_p += index ;
1270+ }
1271+ else
1272+ {
1273+ for (int i = 0 ; i < index ; i ++ )
1274+ {
1275+ lit_utf8_incr (& input_curr_p );
1276+ }
12701277 }
12711278 }
12721279
@@ -1328,8 +1335,15 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
13281335 if (sub_str_p != NULL
13291336 && input_buffer_p != NULL )
13301337 {
1331- lastindex_num = (ecma_number_t ) lit_utf8_string_length (input_buffer_p ,
1332- (lit_utf8_size_t ) (sub_str_p - input_buffer_p ));
1338+ if (input_str_len == input_buffer_size )
1339+ {
1340+ lastindex_num = (ecma_number_t ) (sub_str_p - input_buffer_p );
1341+ }
1342+ else
1343+ {
1344+ lastindex_num = (ecma_number_t ) lit_utf8_string_length (input_buffer_p ,
1345+ (lit_utf8_size_t ) (sub_str_p - input_buffer_p ));
1346+ }
13331347 }
13341348 else
13351349 {
0 commit comments