Skip to content

Commit

Permalink
Git issue 525: segfault when fuzzy matching empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Barnett committed Apr 16, 2024
1 parent 4f2ed52 commit 5d65c8a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions regex_3/_regex_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,9 @@ def get_firstset(self, reverse):
return fs or set([None])

def _compile(self, reverse, fuzzy):
if not self.branches:
return []

code = [(OP.BRANCH, )]
for b in self.branches:
code.extend(b.compile(reverse, fuzzy))
Expand Down
2 changes: 1 addition & 1 deletion regex_3/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
"VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__",
"__doc__", "RegexFlag"]

__version__ = "2.5.140"
__version__ = "2.5.141"

# --------------------------------------------------------------------
# Public interface.
Expand Down
3 changes: 3 additions & 0 deletions regex_3/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4326,6 +4326,9 @@ def test_hg_bugs(self):
self.assertEqual(regex.match(r'(?(?!a).|..)', 'ab').span(), (0, 2))
self.assertEqual(regex.match(r'(?(?!b).|..)', 'ab').span(), (0, 1))

# Git issue 525: segfault when fuzzy matching empty list
self.assertEqual(regex.match(r"(\L<foo>){e<=5}", "blah", foo=[]).span(), (0, 0))

def test_fuzzy_ext(self):
self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', 'e')),
True)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='regex',
version='2023.12.25',
version='2024.4.16',
description='Alternative regular expression module, to replace re.',
long_description=long_description,
long_description_content_type='text/x-rst',
Expand Down

0 comments on commit 5d65c8a

Please sign in to comment.