summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2011-10-04 02:48:30 (GMT)
committerMeador Inge <meadori@gmail.com>2011-10-04 02:48:30 (GMT)
commit29f43f7368115c47c97acff02816a680c3ebd73e (patch)
treec1755ccd2aed68c389121f1a94044a7e89d9a06e /Lib
parent7f3140ef800872716bebaa2e605e0304b6f7ff1b (diff)
parent1efb33a6823b94739e59d6e2fe92e8e703a7fc7d (diff)
downloadcpython-29f43f7368115c47c97acff02816a680c3ebd73e.zip
cpython-29f43f7368115c47c97acff02816a680c3ebd73e.tar.gz
cpython-29f43f7368115c47c97acff02816a680c3ebd73e.tar.bz2
Issue #12881: ctypes: Fix segfault with large structure field names.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_structures.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index e4530d5..b6d8b01 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -326,6 +326,18 @@ class StructureTestCase(unittest.TestCase):
else:
self.assertEqual(msg, "(Phone) TypeError: too many initializers")
+ def test_huge_field_name(self):
+ # issue12881: segfault with large structure field names
+ def create_class(length):
+ class S(Structure):
+ _fields_ = [('x' * length, c_int)]
+
+ for length in [10 ** i for i in range(0, 8)]:
+ try:
+ create_class(length)
+ except MemoryError:
+ # MemoryErrors are OK, we just don't want to segfault
+ pass
def get_except(self, func, *args):
try: