summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Krah <stefan@bytereef.org>2010-11-26 15:08:59 (GMT)
committerStefan Krah <stefan@bytereef.org>2010-11-26 15:08:59 (GMT)
commit40b61237bd2a9457e3475a14329415ea2cc68775 (patch)
tree7bb7da94423d554174b22cc68808caeedb65857c
parent55aa2f39a302be51de631e8cd6da77c054d8447e (diff)
downloadcpython-40b61237bd2a9457e3475a14329415ea2cc68775.zip
cpython-40b61237bd2a9457e3475a14329415ea2cc68775.tar.gz
cpython-40b61237bd2a9457e3475a14329415ea2cc68775.tar.bz2
Merged revisions 86804 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86804 | stefan.krah | 2010-11-26 13:58:05 +0100 (Fri, 26 Nov 2010) | 1 line Issue #10383: Fix two leaks. ........
-rw-r--r--Modules/posixmodule.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index ed2447b..cf8c162 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5138,8 +5138,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
@@ -5166,12 +5168,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);
@@ -5992,10 +5996,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);
@@ -6178,7 +6182,7 @@ posix_confstr(PyObject *self, PyObject *args)
char buffer[256];
if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) {
- int len;
+ int len;
errno = 0;
len = confstr(name, buffer, sizeof(buffer));