Skip to content

Commit 2907d93

Browse files
Fix a possible reference leak in _socket.getaddrinfo(). (GH-10543)
"single" needs to be decrefed if PyList_Append() fails. (cherry picked from commit 4c596d5) Co-authored-by: Zackery Spytz <[email protected]>
1 parent b6f4472 commit 2907d93

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Modules/socketmodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4249,9 +4249,11 @@ socket_getaddrinfo(PyObject *self, PyObject *args)
42494249
if (single == NULL)
42504250
goto err;
42514251

4252-
if (PyList_Append(all, single))
4252+
if (PyList_Append(all, single)) {
4253+
Py_DECREF(single);
42534254
goto err;
4254-
Py_XDECREF(single);
4255+
}
4256+
Py_DECREF(single);
42554257
}
42564258
Py_XDECREF(idna);
42574259
if (res0)

0 commit comments

Comments
 (0)