LibRegex: Use code unit length in more places that apply

Finishes what 7f6b70fafb started.
Having one part use length and another code unit length lead to crashes,
the added test ensures we don't mess that up again.
This commit is contained in:
Ali Mohammad Pur 2025-07-24 20:24:55 +02:00 committed by Jelle Raaijmakers
parent 97c8fdd042
commit c7ad6cd508
Notes: github-actions[bot] 2025-07-24 21:10:34 +00:00
2 changed files with 5 additions and 4 deletions

View file

@ -387,7 +387,7 @@ ALWAYS_INLINE ExecutionResult OpCode_SaveRightCaptureGroup::execute(MatchInput c
if (start_position < match.column)
return ExecutionResult::Continue;
VERIFY(start_position + length <= input.view.length());
VERIFY(start_position + length <= input.view.length_in_code_units());
auto captured_text = input.view.substring_view(start_position, length);
@ -420,7 +420,7 @@ ALWAYS_INLINE ExecutionResult OpCode_SaveRightNamedCaptureGroup::execute(MatchIn
if (start_position < match.column)
return ExecutionResult::Continue;
VERIFY(start_position + length <= input.view.length());
VERIFY(start_position + length <= input.view.length_in_code_units());
auto view = input.view.substring_view(start_position, length);
@ -551,7 +551,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(MatchInput const& input, M
break;
}
case CharacterCompareType::CharClass: {
if (input.view.length() <= state.string_position_in_code_units)
if (input.view.length_in_code_units() <= state.string_position_in_code_units)
return ExecutionResult::Failed_ExecuteLowPrioForks;
auto character_class = (CharClass)m_bytecode->at(offset++);