summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 1ae7ab7..4ec68e2 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -5401,8 +5401,8 @@ sock_initobj_impl(PySocketSockObject *self, int family, int type, int proto,
}
if (!SetHandleInformation((HANDLE)fd, HANDLE_FLAG_INHERIT, 0)) {
- closesocket(fd);
PyErr_SetFromWindowsErr(0);
+ closesocket(fd);
return -1;
}
@@ -5616,8 +5616,9 @@ socket_gethostname(PyObject *self, PyObject *unused)
name,
&size))
{
+ PyErr_SetFromWindowsErr(0);
PyMem_Free(name);
- return PyErr_SetFromWindowsErr(0);
+ return NULL;
}
result = PyUnicode_FromWideChar(name, size);
@@ -6215,8 +6216,8 @@ socket_dup(PyObject *self, PyObject *fdobj)
}
if (!SetHandleInformation((HANDLE)newfd, HANDLE_FLAG_INHERIT, 0)) {
- closesocket(newfd);
PyErr_SetFromWindowsErr(0);
+ closesocket(newfd);
return NULL;
}
#else
@@ -6663,11 +6664,12 @@ socket_inet_ntop(PyObject *self, PyObject *args)
/* inet_ntop guarantee NUL-termination of resulting string. */
retval = inet_ntop(af, packed_ip.buf, ip, sizeof(ip));
- PyBuffer_Release(&packed_ip);
if (!retval) {
PyErr_SetFromErrno(PyExc_OSError);
+ PyBuffer_Release(&packed_ip);
return NULL;
} else {
+ PyBuffer_Release(&packed_ip);
return PyUnicode_FromString(retval);
}
}
@@ -7006,8 +7008,8 @@ socket_if_nameindex(PyObject *self, PyObject *arg)
ni = if_nameindex();
if (ni == NULL) {
- Py_DECREF(list);
PyErr_SetFromErrno(PyExc_OSError);
+ Py_DECREF(list);
return NULL;
}