mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Issue #12881: ctypes: Fix segfault with large structure field names.
This commit is contained in:
commit
29f43f7368
3 changed files with 21 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue