https://github.com/python/cpython/commit/2b6e77e778bc6f5b69384d6c13cb2015c13fc81e commit: 2b6e77e778bc6f5b69384d6c13cb2015c13fc81e branch: 3.6 author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com> committer: GitHub <noreply at github.com> date: 2018年11月15日T01:25:46-08:00 summary: 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 <zspytz at gmail.com> files: M Modules/socketmodule.c diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index ed3166740278..c940f1b81693 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -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)