Skip to content

Commit 5624bf9

Browse files
[3.13] gh-143145: Fix possible reference leak in ctypes _build_result() (GH-143131) (GH-143170)
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 80f7d49 commit 5624bf9

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
@@ -4273,6 +4273,7 @@ _build_result(PyObject *result, PyObject *callargs,
42734273
v = PyTuple_GET_ITEM(callargs, i);
42744274
v = PyObject_CallMethodNoArgs(v, &_Py_ID(__ctypes_from_outparam__));
42754275
if (v == NULL || numretvals == 1) {
4276+
Py_XDECREF(tup);
42764277
Py_DECREF(callargs);
42774278
return v;
42784279
}

0 commit comments

Comments
 (0)