]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.11] gh-62260: Fix ctypes.Structure subclassing with multiple layers (GH-13374...
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 1 Jan 2024 16:46:07 +0000 (18:46 +0200)
committerGitHub <noreply@github.com>
Mon, 1 Jan 2024 16:46:07 +0000 (16:46 +0000)
commit36153494f1fe3182bb1fdef89839b594a70d570d
treeb752b8b91c720d74efb92b1f32bc4241d48b823b
parent51691133795814a3ac3bc84e938238eb0e720d8f
[3.11] gh-62260: Fix ctypes.Structure subclassing with multiple layers (GH-13374) (GH-113624)

The length field of StgDictObject for Structure class contains now
the total number of items in ffi_type_pointer.elements (excluding
the trailing null).

The old behavior of using the number of elements in the parent class can
cause the array to be truncated when it is copied, especially when there
are multiple layers of subclassing.

(cherry picked from commit 5f3cc90a12d6df404fd6f48a0df1334902e271f2)

Co-authored-by: Jeffrey Kintscher <49998481+websurfer5@users.noreply.github.com>
Lib/ctypes/test/test_structures.py
Misc/NEWS.d/next/Library/2019-05-17-07-22-33.bpo-18060.5mqTQM.rst [new file with mode: 0644]
Modules/_ctypes/_ctypes.c
Modules/_ctypes/stgdict.c