diff options
author | Stefan Krah <stefan@bytereef.org> | 2010-11-26 12:58:05 (GMT) |
---|---|---|
committer | Stefan Krah <stefan@bytereef.org> | 2010-11-26 12:58:05 (GMT) |
commit | 99439266a3ef4f13d2461118b9d898451edc8aad (patch) | |
tree | 557717ddca64e7b9a94975b244f27e4fd0dd46bb /Modules/posixmodule.c | |
parent | fe12390b45ac5ac8080461d21e0471e4a690dc71 (diff) | |
download | cpython-99439266a3ef4f13d2461118b9d898451edc8aad.zip cpython-99439266a3ef4f13d2461118b9d898451edc8aad.tar.gz cpython-99439266a3ef4f13d2461118b9d898451edc8aad.tar.bz2 |
Issue #10383: Fix two leaks.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8b7d7e9..7d6e7b3 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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,12 +5650,14 @@ 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 - PyBuffer_Release(&pbuf); + PyBuffer_Release(&pbuf); if (size < 0) return posix_error(); return PyLong_FromSsize_t(size); @@ -6540,10 +6544,10 @@ posix_pathconf(PyObject *self, PyObject *args) limit = pathconf(path, name); if (limit == -1 && errno != 0) { if (errno == EINVAL) - /* could be a path or name problem */ - posix_error(); + /* could be a path or name problem */ + posix_error(); else - posix_error_with_filename(path); + posix_error_with_filename(path); } else result = PyLong_FromLong(limit); @@ -6724,7 +6728,7 @@ posix_confstr(PyObject *self, PyObject *args) PyObject *result = NULL; int name; char buffer[255]; - int len; + int len; if (!PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) return NULL; |