diff options
author | Meador Inge <meadori@gmail.com> | 2011-10-04 02:44:22 (GMT) |
---|---|---|
committer | Meador Inge <meadori@gmail.com> | 2011-10-04 02:44:22 (GMT) |
commit | 1efb33a6823b94739e59d6e2fe92e8e703a7fc7d (patch) | |
tree | 86f8d676cb9b8ca47f20e63f8533de58b8e0c28c /Lib/ctypes | |
parent | 5d0de3fbaa6d3c6ba9c1c510a943df249bdd61e7 (diff) | |
download | cpython-1efb33a6823b94739e59d6e2fe92e8e703a7fc7d.zip cpython-1efb33a6823b94739e59d6e2fe92e8e703a7fc7d.tar.gz cpython-1efb33a6823b94739e59d6e2fe92e8e703a7fc7d.tar.bz2 |
Issue #12881: ctypes: Fix segfault with large structure field names.
Diffstat (limited to 'Lib/ctypes')
-rw-r--r-- | Lib/ctypes/test/test_structures.py | 12 |
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: |