mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
Avoid possible undefined behaviour from signed overflow.
This commit is contained in:
parent
1c164a6f85
commit
ab4096f2f9
2 changed files with 11 additions and 3 deletions
|
@ -506,6 +506,11 @@ class StructTest(unittest.TestCase):
|
|||
for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']:
|
||||
self.assertTrue(struct.unpack('>?', c)[0])
|
||||
|
||||
def test_count_overflow(self):
|
||||
hugecount = '{}b'.format(sys.maxsize+1)
|
||||
self.assertRaises(struct.error, struct.calcsize, hugecount)
|
||||
|
||||
|
||||
if IS32BIT:
|
||||
def test_crasher(self):
|
||||
self.assertRaises(MemoryError, struct.pack, "357913941b", "a")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue