mirror of
https://github.com/python/cpython.git
synced 2026-06-22 19:12:50 -04:00
gh-151021: Fix mmap empty searches past the end (GH-151023)
This commit is contained in:
@@ -354,6 +354,8 @@ class MmapTests(unittest.TestCase):
|
||||
self.assertEqual(m.find(b'one', 1, -1), 8)
|
||||
self.assertEqual(m.find(b'one', 1, -2), -1)
|
||||
self.assertEqual(m.find(bytearray(b'one')), 0)
|
||||
self.assertEqual(m.find(b'', n + 1), -1)
|
||||
self.assertEqual(m.rfind(b'', n + 1), -1)
|
||||
|
||||
for i in range(-n-1, n+1):
|
||||
for j in range(-n-1, n+1):
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Fix :meth:`mmap.mmap.find` and :meth:`~mmap.mmap.rfind` to return ``-1``
|
||||
when searching for an empty subsequence with a start position past the end
|
||||
of the mapping.
|
||||
@@ -620,8 +620,6 @@ mmap_gfind_lock_held(mmap_object *self, Py_buffer *view, PyObject *start_obj,
|
||||
start += self->size;
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
else if (start > self->size)
|
||||
start = self->size;
|
||||
|
||||
if (end < 0)
|
||||
end += self->size;
|
||||
|
||||
Reference in New Issue
Block a user