]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.11] gh-99952: fix refcount issues in ctypes.Structure from_param() result (#101339)
authorGregory P. Smith <greg@krypto.org>
Thu, 26 Jan 2023 09:02:37 +0000 (01:02 -0800)
committerGitHub <noreply@github.com>
Thu, 26 Jan 2023 09:02:37 +0000 (01:02 -0800)
commitfa7c37af4936abfe34aa261d6ed9703bc5842ad4
tree96f09140d9b98fa253e2f911f735c8d9854818d4
parentcd0fe5ba09df65bdee90738129b7315a936b83fb
[3.11] gh-99952: fix refcount issues in ctypes.Structure from_param() result (#101339)

[3.11] gh-99952: [ctypes] fix refcount issues in from_param() result. (GH-100169)

Fixes a reference counting issue with `ctypes.Structure` when a `from_param()` method call is used and the structure size is larger than a C pointer `sizeof(void*)`.

This problem existed for a very long time, but became more apparent in 3.8+ by change likely due to garbage collection cleanup timing changes..
(cherry picked from commit dfad678d7024ab86d265d84ed45999e031a03691)

Co-authored-by: Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>
Lib/ctypes/test/test_parameters.py
Misc/NEWS.d/next/Library/2022-12-11-14-38-59.gh-issue-99952.IYGLzr.rst [new file with mode: 0644]
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes_test.c