mirror of
https://github.com/python/cpython.git
synced 2026-06-10 11:52:01 +00:00
gh-151021: Fix mmap empty searches past the end (GH-151023)
This commit is contained in:
parent
0f7dc2fefa
commit
f2cab7b0cf
3 changed files with 5 additions and 2 deletions
|
|
@ -354,6 +354,8 @@ def test_find_end(self):
|
|||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue