-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Bug: FilteredRE2::AllMatches and AllPotentials missing compiled_ check #613
Copy link
Copy link
Open
Description
Description
FilteredRE2::FirstMatch() checks the compiled_ flag before proceeding and logs a DFATAL if Compile() was not called. However, AllMatches() and AllPotentials() skip this check. Calling them before Compile() leads to unexpected behavior because the prefilter tree has not been built.
This is the same class of bug that was fixed for Filter.Match() in the Python bindings (issue #484), where calling Match before Compile caused a segfault.
Code
FirstMatch has the guard (line 100):
int FilteredRE2::FirstMatch(absl::string_view text,
const std::vector<int>& atoms) const {
if (!compiled_) {
ABSL_LOG(DFATAL) << "FirstMatch called before Compile.";
return -1;
}
...
}AllMatches (line 112) and AllPotentials (line 124) lack it:
bool FilteredRE2::AllMatches(absl::string_view text,
const std::vector<int>& atoms,
std::vector<int>* matching_regexps) const {
matching_regexps->clear();
// No compiled_ check here.
...
}I can open a PR to submit a fix.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels