Skip to content

Commit 45642ba

Browse files
author
Matthew Barnett
committed
Git issue 479: Segmentation fault when using conditional pattern
Crashed due to dereference of wrong (null) pointer.
1 parent 71be78a commit 45642ba

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

regex_3/_regex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12273,7 +12273,7 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
1227312273
*/
1227412274

1227512275
/* Go to the 'false' branch. */
12276-
node = node->nonstring.next_2.node;
12276+
node = conditional->nonstring.next_2.node;
1227712277
}
1227812278
break;
1227912279
}

regex_3/test_regex.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4325,6 +4325,10 @@ def test_hg_bugs(self):
43254325
self.assertEqual(bool(regex.fullmatch(r'\p{HorizSpace}+', '\t \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000')), True)
43264326
self.assertEqual(bool(regex.fullmatch(r'\p{VertSpace}+', '\n\v\f\r\x85\u2028\u2029')), True)
43274327

4328+
# Git issue 479: Segmentation fault when using conditional pattern
4329+
self.assertEqual(regex.match(r'(?(?<=A)|(?(?![^B])C|D))', 'A'), None)
4330+
self.assertEqual(regex.search(r'(?(?<=A)|(?(?![^B])C|D))', 'A').span(), (1, 1))
4331+
43284332
def test_fuzzy_ext(self):
43294333
self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', 'e')),
43304334
True)

0 commit comments

Comments
 (0)