Skip to content

Commit 88a4d0d

Browse files
[3.14] gh-143145: Fix possible reference leak in ctypes _build_result() (GH-143131) (GH-143169)
The result tuple was leaked if __ctypes_from_outparam__() failed for any item. (cherry picked from commit 579c5b4) Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com> Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com>
1 parent 8a61b71 commit 88a4d0d

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a possible reference leak in ctypes when constructing results with multiple output parameters on error.

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,6 +4551,7 @@ _build_result(PyObject *result, PyObject *callargs,
45514551
v = PyTuple_GET_ITEM(callargs, i);
45524552
v = PyObject_CallMethodNoArgs(v, &_Py_ID(__ctypes_from_outparam__));
45534553
if (v == NULL || numretvals == 1) {
4554+
Py_XDECREF(tup);
45544555
Py_DECREF(callargs);
45554556
return v;
45564557
}

0 commit comments

Comments
 (0)