mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Issue #10383: Fix two leaks.
This commit is contained in:
parent
fe12390b45
commit
99439266a3
1 changed files with 11 additions and 7 deletions
|
|
@ -5620,8 +5620,10 @@ posix_read(PyObject *self, PyObject *args)
|
|||
buffer = PyBytes_FromStringAndSize((char *)NULL, size);
|
||||
if (buffer == NULL)
|
||||
return NULL;
|
||||
if (!_PyVerify_fd(fd))
|
||||
if (!_PyVerify_fd(fd)) {
|
||||
Py_DECREF(buffer);
|
||||
return posix_error();
|
||||
}
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
n = read(fd, PyBytes_AS_STRING(buffer), size);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
|
@ -5648,8 +5650,10 @@ posix_write(PyObject *self, PyObject *args)
|
|||
|
||||
if (!PyArg_ParseTuple(args, "iy*:write", &fd, &pbuf))
|
||||
return NULL;
|
||||
if (!_PyVerify_fd(fd))
|
||||
if (!_PyVerify_fd(fd)) {
|
||||
PyBuffer_Release(&pbuf);
|
||||
return posix_error();
|
||||
}
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
size = write(fd, pbuf.buf, (size_t)pbuf.len);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue