]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix a possible reference leak in _socket.getaddrinfo(). (GH-10543)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 15 Nov 2018 09:25:46 +0000 (01:25 -0800)
committerGitHub <noreply@github.com>
Thu, 15 Nov 2018 09:25:46 +0000 (01:25 -0800)
"single" needs to be decrefed if PyList_Append() fails.
(cherry picked from commit 4c596d54aa6a55e9d2a3db78891e656ebbfb63c8)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Modules/socketmodule.c

index ed3166740278b487591ca44d65bd99727bf53a6a..c940f1b81693c76f322724182fe695f5b73164b6 100644 (file)
@@ -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)