Skip to content

Commit 4f93e9b

Browse files
hyongtao-codemiss-islington
authored andcommitted
gh-143145: Fix possible reference leak in ctypes _build_result() (GH-143131)
The result tuple was leaked if __ctypes_from_outparam__() failed for any item. (cherry picked from commit 579c5b4) Co-authored-by: Yongtao Huang <yongtaoh2022@gmail.com> Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
1 parent 80f7d49 commit 4f93e9b

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)