Skip to content

Commit

Permalink
fix: ensure that the list of threads in EpsilonClosureState is empt…
Browse files Browse the repository at this point in the history
…y after exiting `try_match`

The list of threads in`EpsilonClosureState` must be empty when exiting `try_match` so that further calls to this function finds an empty list. Before this change the some threads were kept in the list when exiting early due to reaching `scan_limit`.
  • Loading branch information
plusvic committed Aug 16, 2023
1 parent 20c6bbc commit 4cf81fa
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions yara-x/src/re/pikevm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<'r> PikeVM<'r> {
&mut self.threads,
);

while !self.threads.is_empty() {
while !self.threads.is_empty() && current_pos < self.scan_limit {
let next_byte = fwd_input.next();

for ip in self.threads.iter() {
Expand Down Expand Up @@ -161,10 +161,6 @@ impl<'r> PikeVM<'r> {
curr_byte = next_byte;
current_pos += step;

if current_pos > self.scan_limit {
break;
}

mem::swap(&mut self.threads, &mut self.next_threads);
self.next_threads.clear();
}
Expand Down

0 comments on commit 4cf81fa

Please sign in to comment.