[pypy-commit] pypy default: issue #3065 strikes again! fix segfault in mmap
cfbolz
pypy.commits at gmail.com
Fri Jan 31 08:12:10 EST 2020
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch:
Changeset: r98609:d22a7659ed80
Date: 2020-01-31 14:04 +0100
http://bitbucket.org/pypy/pypy/changeset/d22a7659ed80/
Log: issue #3065 strikes again! fix segfault in mmap
diff --git a/pypy/module/mmap/interp_mmap.py b/pypy/module/mmap/interp_mmap.py
--- a/pypy/module/mmap/interp_mmap.py
+++ b/pypy/module/mmap/interp_mmap.py
@@ -177,8 +177,10 @@
return space.newbytes(self.mmap.getslice(start, length))
else:
b = StringBuilder(length)
- for i in range(start, stop, step):
- b.append(self.mmap.getitem(i))
+ index = start
+ for i in range(length):
+ b.append(self.mmap.getitem(index))
+ index += step
return space.newbytes(b.build())
def descr_setitem(self, w_index, w_value):
diff --git a/pypy/module/mmap/test/test_mmap.py b/pypy/module/mmap/test/test_mmap.py
--- a/pypy/module/mmap/test/test_mmap.py
+++ b/pypy/module/mmap/test/test_mmap.py
@@ -433,6 +433,15 @@
m.close()
f.close()
+ def test_get_crash(self):
+ import sys
+ from mmap import mmap
+ s = b'hallo!!!'
+ m = mmap(-1, len(s))
+ m[:] = s
+ assert m[1:None:sys.maxsize] == b'a'
+ m.close()
+
def test_set_item(self):
import mmap
More information about the pypy-commit
mailing list