[3.14] gh-139748: fix leaks in AC error paths when using unicode FS-b… (#139789)

* [3.14] gh-139748: fix leaks in AC error paths when using unicode FS-based converters (GH-139765)
(cherry picked from commit b04a57deef)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
Kumar Aditya 2025-10-08 22:16:21 +05:30 committed by GitHub
parent 077652b44f
commit 90cd009209
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 88 additions and 46 deletions

View file

@ -7261,7 +7261,7 @@ Returns a list of network interface information (index, name) tuples.");
/*[clinic input]
_socket.if_nametoindex
oname: object(converter="PyUnicode_FSConverter")
oname: unicode_fs_encoded
/
Returns the interface index corresponding to the interface name if_name.
@ -7269,7 +7269,7 @@ Returns the interface index corresponding to the interface name if_name.
static PyObject *
_socket_if_nametoindex_impl(PyObject *module, PyObject *oname)
/*[clinic end generated code: output=289a411614f30244 input=01e0f1205307fb77]*/
/*[clinic end generated code: output=289a411614f30244 input=6125dc20683560cf]*/
{
#ifdef MS_WINDOWS
NET_IFINDEX index;
@ -7278,7 +7278,6 @@ _socket_if_nametoindex_impl(PyObject *module, PyObject *oname)
#endif
index = if_nametoindex(PyBytes_AS_STRING(oname));
Py_DECREF(oname);
if (index == 0) {
/* if_nametoindex() doesn't set errno */
PyErr_SetString(PyExc_OSError, "no interface with this name");