if (ncmsgbufs > 0) {
struct cmsghdr *cmsgh = NULL;
- if ((msg.msg_control = controlbuf =
- PyMem_Malloc(controllen)) == NULL) {
+ controlbuf = PyMem_Malloc(controllen);
+ if (controlbuf == NULL) {
PyErr_NoMemory();
goto finally;
}
+ msg.msg_control = controlbuf;
+
msg.msg_controllen = controllen;
/* Need to zero out the buffer as a workaround for glibc's
PyBuffer_Release(&cmsgs[i].data);
PyMem_Free(cmsgs);
Py_XDECREF(cmsg_fast);
- for (i = 0; i < ndatabufs; i++)
+ PyMem_Free(msg.msg_iov);
+ for (i = 0; i < ndatabufs; i++) {
PyBuffer_Release(&databufs[i]);
+ }
PyMem_Free(databufs);
return retval;
}
controlbuf = PyMem_Malloc(controllen);
if (controlbuf == NULL) {
- return PyErr_NoMemory();
+ PyErr_NoMemory();
+ goto finally;
}
memset(controlbuf, 0, controllen);
if (iv.buf != NULL) {
PyBuffer_Release(&iv);
}
- for (i = 0; i < ndatabufs; i++)
+ PyMem_Free(msg.msg_iov);
+ for (i = 0; i < ndatabufs; i++) {
PyBuffer_Release(&databufs[i]);
+ }
PyMem_Free(databufs);
return retval;
}