RE_Match_State: Do not reset current_pos for every Match() call

This seems like a bug: If one feeds one byte at a time, current_pos
is being reset for every byte, possibly reporting the wrong offsets
in the accepted_matches map.
This commit is contained in:
Arne Welzel 2023-11-15 19:41:27 +01:00
parent b0a200a5dc
commit 56830948e3

View file

@ -268,6 +268,7 @@ bool RE_Match_State::Match(const u_char* bv, int n, bool bol, bool eol, bool cle
// Initialize state and copy the accepting states of the start
// state into the acceptance set.
current_pos = 0;
current_state = dfa->StartState();
const AcceptingSet* ac = current_state->Accept();
@ -276,13 +277,14 @@ bool RE_Match_State::Match(const u_char* bv, int n, bool bol, bool eol, bool cle
AddMatches(*ac, 0);
}
else if ( clear )
else if ( clear ) {
current_pos = 0;
current_state = dfa->StartState();
}
if ( ! current_state )
return false;
current_pos = 0;
size_t old_matches = accepted_matches.size();