Skip to content

Commit

Permalink
Fix a possible reference leak in _socket.getaddrinfo(). (pythonGH-10543)
Browse files Browse the repository at this point in the history
"single" needs to be decrefed if PyList_Append() fails.
(cherry picked from commit 4c596d5)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
  • Loading branch information
ZackerySpytz authored and miss-islington committed Nov 14, 2018
1 parent 137da0c commit 5e84596
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6075,9 +6075,11 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
if (single == NULL)
goto err;

if (PyList_Append(all, single))
if (PyList_Append(all, single)) {
Py_DECREF(single);
goto err;
Py_XDECREF(single);
}
Py_DECREF(single);
}
Py_XDECREF(idna);
if (res0)
Expand Down

0 comments on commit 5e84596

Please sign in to comment.