From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 15 Nov 2018 09:25:58 +0000 (-0800) Subject: Fix a possible reference leak in _socket.getaddrinfo(). (GH-10543) X-Git-Tag: v2.7.16rc1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2907d93889b67cda4041c4cb716521ee70af3703;p=thirdparty%2FPython%2Fcpython.git Fix a possible reference leak in _socket.getaddrinfo(). (GH-10543) "single" needs to be decrefed if PyList_Append() fails. (cherry picked from commit 4c596d54aa6a55e9d2a3db78891e656ebbfb63c8) Co-authored-by: Zackery Spytz --- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 634c1b90778b..013975455c45 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -4249,9 +4249,11 @@ socket_getaddrinfo(PyObject *self, PyObject *args) 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)