summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-06-11 16:56:34 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-06-11 16:56:34 (GMT)
commitab4096f2f9cc3f2a06e24d8dbe9c3e8e0ba155f0 (patch)
tree535bc73bf3c05c67c928e1d13cd6c519c1e9e832 /Lib/test/test_struct.py
parent1c164a6f85865ab6c84d4bfb6bfbf1dde6169603 (diff)
downloadcpython-ab4096f2f9cc3f2a06e24d8dbe9c3e8e0ba155f0.zip
cpython-ab4096f2f9cc3f2a06e24d8dbe9c3e8e0ba155f0.tar.gz
cpython-ab4096f2f9cc3f2a06e24d8dbe9c3e8e0ba155f0.tar.bz2
Avoid possible undefined behaviour from signed overflow.
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r--Lib/test/test_struct.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index b9faa28..70eed6e 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -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")