Issue #29444: Fixed out-of-bounds buffer access in the group() method of

the match object.  Based on patch by WGH.
This commit is contained in:
Serhiy Storchaka 2017-02-04 22:57:44 +02:00
commit ef5176769d
3 changed files with 20 additions and 2 deletions

View file

@ -1821,6 +1821,16 @@ SUBPATTERN None 0 0
warnings.simplefilter('error', BytesWarning)
self.assertNotEqual(pattern3, pattern1)
def test_bug_29444(self):
s = bytearray(b'abcdefgh')
m = re.search(b'[a-h]+', s)
m2 = re.search(b'[e-h]+', s)
self.assertEqual(m.group(), b'abcdefgh')
self.assertEqual(m2.group(), b'efgh')
s[:] = b'xyz'
self.assertEqual(m.group(), b'xyz')
self.assertEqual(m2.group(), b'')
class PatternReprTests(unittest.TestCase):
def check(self, pattern, expected):