diff options
author | Meador Inge <meadori@gmail.com> | 2011-10-04 02:34:04 (GMT) |
---|---|---|
committer | Meador Inge <meadori@gmail.com> | 2011-10-04 02:34:04 (GMT) |
commit | ad349a190e923b32e7ef43ddafffde93df75051a (patch) | |
tree | e4b1751719ea6cc935e1f56fd9f904db17b22f55 /Lib/ctypes/test | |
parent | 83cc512a01d33d5e6fcc3be2ce62a9a644dd3b50 (diff) | |
download | cpython-ad349a190e923b32e7ef43ddafffde93df75051a.zip cpython-ad349a190e923b32e7ef43ddafffde93df75051a.tar.gz cpython-ad349a190e923b32e7ef43ddafffde93df75051a.tar.bz2 |
Issue #12881: ctypes: Fix segfault with large structure field names.
Diffstat (limited to 'Lib/ctypes/test')
-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 a84bae0..1bde101 100644 --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -332,6 +332,18 @@ class StructureTestCase(unittest.TestCase): else: self.assertEqual(msg, "(Phone) exceptions.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: |