Kaydet (Commit) 99439266 authored tarafından Stefan Krah's avatar Stefan Krah

Issue #10383: Fix two leaks.

üst fe12390b
...@@ -5620,8 +5620,10 @@ posix_read(PyObject *self, PyObject *args) ...@@ -5620,8 +5620,10 @@ posix_read(PyObject *self, PyObject *args)
buffer = PyBytes_FromStringAndSize((char *)NULL, size); buffer = PyBytes_FromStringAndSize((char *)NULL, size);
if (buffer == NULL) if (buffer == NULL)
return NULL; return NULL;
if (!_PyVerify_fd(fd)) if (!_PyVerify_fd(fd)) {
Py_DECREF(buffer);
return posix_error(); return posix_error();
}
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
n = read(fd, PyBytes_AS_STRING(buffer), size); n = read(fd, PyBytes_AS_STRING(buffer), size);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
...@@ -5648,12 +5650,14 @@ posix_write(PyObject *self, PyObject *args) ...@@ -5648,12 +5650,14 @@ posix_write(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "iy*:write", &fd, &pbuf)) if (!PyArg_ParseTuple(args, "iy*:write", &fd, &pbuf))
return NULL; return NULL;
if (!_PyVerify_fd(fd)) if (!_PyVerify_fd(fd)) {
PyBuffer_Release(&pbuf);
return posix_error(); return posix_error();
}
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
size = write(fd, pbuf.buf, (size_t)pbuf.len); size = write(fd, pbuf.buf, (size_t)pbuf.len);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
PyBuffer_Release(&pbuf); PyBuffer_Release(&pbuf);
if (size < 0) if (size < 0)
return posix_error(); return posix_error();
return PyLong_FromSsize_t(size); return PyLong_FromSsize_t(size);
...@@ -6540,10 +6544,10 @@ posix_pathconf(PyObject *self, PyObject *args) ...@@ -6540,10 +6544,10 @@ posix_pathconf(PyObject *self, PyObject *args)
limit = pathconf(path, name); limit = pathconf(path, name);
if (limit == -1 && errno != 0) { if (limit == -1 && errno != 0) {
if (errno == EINVAL) if (errno == EINVAL)
/* could be a path or name problem */ /* could be a path or name problem */
posix_error(); posix_error();
else else
posix_error_with_filename(path); posix_error_with_filename(path);
} }
else else
result = PyLong_FromLong(limit); result = PyLong_FromLong(limit);
...@@ -6724,7 +6728,7 @@ posix_confstr(PyObject *self, PyObject *args) ...@@ -6724,7 +6728,7 @@ posix_confstr(PyObject *self, PyObject *args)
PyObject *result = NULL; PyObject *result = NULL;
int name; int name;
char buffer[255]; char buffer[255];
int len; int len;
if (!PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) if (!PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name))
return NULL; return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment