Dont leak a file descriptor if pthread_create() fails
This commit is contained in:
parent
55969bc3c5
commit
2973cf15a4
1 changed files with 1 additions and 1 deletions
|
|
@ -809,7 +809,7 @@ cm_thread_write(PyObject UNUSED *self, PyObject *args) {
|
|||
data->fd = fd;
|
||||
memcpy(data->buf, buf, data->sz);
|
||||
int ret = pthread_create(&thread, NULL, thread_write, data);
|
||||
if (ret != 0) { free_twd(data); return PyErr_SetFromErrno(PyExc_OSError); }
|
||||
if (ret != 0) { close(fd); free_twd(data); return PyErr_SetFromErrno(PyExc_OSError); }
|
||||
pthread_detach(thread);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue