Issue #18025: Fixed a segfault in io.BufferedIOBase.readinto() when raw

stream's read() returns more bytes than requested.
This commit is contained in:
Serhiy Storchaka 2013-05-28 16:24:45 +03:00
parent 12516e2c1b
commit 37a79a12d1
3 changed files with 20 additions and 0 deletions

View file

@ -3019,6 +3019,15 @@ class MiscIOTest(unittest.TestCase):
class CMiscIOTest(MiscIOTest):
io = io
def test_readinto_buffer_overflow(self):
# Issue #18025
class BadReader(self.io.BufferedIOBase):
def read(self, n=-1):
return b'x' * 10**6
bufio = BadReader()
b = bytearray(2)
self.assertRaises(ValueError, bufio.readinto, b)
class PyMiscIOTest(MiscIOTest):
io = pyio