1
1
mirror of https://github.com/mrabarnett/mrab-regex.git synced 2025-10-05 20:02:39 +02:00

Git issue 525: segfault when fuzzy matching empty list

This commit is contained in:
Matthew Barnett
2024-04-16 19:33:07 +01:00
parent 4f2ed52b3d
commit 5d65c8a727
4 changed files with 8 additions and 2 deletions

View File

@@ -2111,6 +2111,9 @@ class Branch(RegexBase):
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))

View File

@@ -241,7 +241,7 @@ __all__ = ["cache_all", "compile", "DEFAULT_VERSION", "escape", "findall",
"VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__",
"__doc__", "RegexFlag"]
__version__ = "2.5.140"
__version__ = "2.5.141"
# --------------------------------------------------------------------
# Public interface.

View File

@@ -4326,6 +4326,9 @@ thing
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)

View File

@@ -7,7 +7,7 @@ with open('README.rst', encoding='utf-8') as file:
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',