Skip to content

Commit

Permalink
Git issue 479: Segmentation fault when using conditional pattern
Browse files Browse the repository at this point in the history
Crashed due to dereference of wrong (null) pointer.
  • Loading branch information
Matthew Barnett committed Sep 11, 2022
1 parent 71be78a commit 45642ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion regex_3/_regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -12273,7 +12273,7 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
*/

/* Go to the 'false' branch. */
node = node->nonstring.next_2.node;
node = conditional->nonstring.next_2.node;
}
break;
}
Expand Down
4 changes: 4 additions & 0 deletions regex_3/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4325,6 +4325,10 @@ def test_hg_bugs(self):
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)
self.assertEqual(bool(regex.fullmatch(r'\p{VertSpace}+', '\n\v\f\r\x85\u2028\u2029')), True)

# Git issue 479: Segmentation fault when using conditional pattern
self.assertEqual(regex.match(r'(?(?<=A)|(?(?![^B])C|D))', 'A'), None)
self.assertEqual(regex.search(r'(?(?<=A)|(?(?![^B])C|D))', 'A').span(), (1, 1))

def test_fuzzy_ext(self):
self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', 'e')),
True)
Expand Down

0 comments on commit 45642ba

Please sign in to comment.