LibRegex: Restore checkpoints when restoring the state post-fork

Fixes the lockup/OOM in #968.
This commit is contained in:
Ali Mohammad Pur
2024-10-08 19:22:33 +02:00
committed by Andreas Kling
parent 43a07a0fde
commit cc1f0c3af2
3 changed files with 9 additions and 6 deletions

View File

@@ -1072,20 +1072,20 @@ ALWAYS_INLINE ExecutionResult OpCode_ResetRepeat::execute(MatchInput const&, Mat
return ExecutionResult::Continue;
}
ALWAYS_INLINE ExecutionResult OpCode_Checkpoint::execute(MatchInput const& input, MatchState& state) const
ALWAYS_INLINE ExecutionResult OpCode_Checkpoint::execute(MatchInput const&, MatchState& state) const
{
auto id = this->id();
if (id >= input.checkpoints.size())
input.checkpoints.resize(id + 1);
if (id >= state.checkpoints.size())
state.checkpoints.resize(id + 1);
input.checkpoints[id] = state.string_position + 1;
state.checkpoints[id] = state.string_position + 1;
return ExecutionResult::Continue;
}
ALWAYS_INLINE ExecutionResult OpCode_JumpNonEmpty::execute(MatchInput const& input, MatchState& state) const
{
u64 current_position = state.string_position;
auto checkpoint_position = input.checkpoints[checkpoint()];
auto checkpoint_position = state.checkpoints[checkpoint()];
if (checkpoint_position != 0 && checkpoint_position != current_position + 1) {
auto form = this->form();