mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-14 18:22:27 +03:00
matcher: remove an undefined behavior (#10537)
Indexing into a zero-length std::vector is an undefined behavior.
This commit is contained in:
parent
d85117f88c
commit
2ff197603e
|
@ -244,8 +244,12 @@ cdef class Matcher:
|
||||||
pipe = "parser"
|
pipe = "parser"
|
||||||
error_msg = Errors.E155.format(pipe=pipe, attr=self.vocab.strings.as_string(attr))
|
error_msg = Errors.E155.format(pipe=pipe, attr=self.vocab.strings.as_string(attr))
|
||||||
raise ValueError(error_msg)
|
raise ValueError(error_msg)
|
||||||
matches = find_matches(&self.patterns[0], self.patterns.size(), doclike, length,
|
|
||||||
extensions=self._extensions, predicates=self._extra_predicates, with_alignments=with_alignments)
|
if self.patterns.empty():
|
||||||
|
matches = []
|
||||||
|
else:
|
||||||
|
matches = find_matches(&self.patterns[0], self.patterns.size(), doclike, length,
|
||||||
|
extensions=self._extensions, predicates=self._extra_predicates, with_alignments=with_alignments)
|
||||||
final_matches = []
|
final_matches = []
|
||||||
pairs_by_id = {}
|
pairs_by_id = {}
|
||||||
# For each key, either add all matches, or only the filtered,
|
# For each key, either add all matches, or only the filtered,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user