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@gmail.com>
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index eeade2e..ddb1c43 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -6269,9 +6269,11 @@
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)