summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2011-03-19 07:11:14 (GMT)
committerRoss Lagerwall <rosslagerwall@gmail.com>2011-03-19 07:11:14 (GMT)
commit9ad63e091448d8778cde67fce8619baaab7cf10b (patch)
tree8c15ebfdc3dd3c5a13546f4d5ddb2be07b302e24 /Modules
parent952c0782b39d2112c648f0731abf5e566fa20c37 (diff)
downloadcpython-9ad63e091448d8778cde67fce8619baaab7cf10b.zip
cpython-9ad63e091448d8778cde67fce8619baaab7cf10b.tar.gz
cpython-9ad63e091448d8778cde67fce8619baaab7cf10b.tar.bz2
Fix refleak introduced by #10812.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index f873a7a..8f17bf4 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -3827,16 +3827,19 @@ parse_arglist(PyObject* argv, Py_ssize_t *argc)
return NULL;
}
for (i = 0; i < *argc; i++) {
- if (!fsconvert_strdup(PySequence_ITEM(argv, i),
- &argvlist[i]))
- {
- *argc = i;
+ PyObject* item = PySequence_ITEM(argv, i);
+ if (item == NULL)
+ goto fail;
+ if (!fsconvert_strdup(item, &argvlist[i])) {
+ Py_DECREF(item);
goto fail;
}
+ Py_DECREF(item);
}
argvlist[*argc] = NULL;
return argvlist;
fail:
+ *argc = i;
free_string_array(argvlist, *argc);
return NULL;
}
@@ -6177,22 +6180,28 @@ iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, int cnt, int type)
}
for (i = 0; i < cnt; i++) {
- if (PyObject_GetBuffer(PySequence_GetItem(seq, i),
- &(*buf)[i], type) == -1) {
- PyMem_Del(*iov);
- for (j = 0; j < i; j++) {
- PyBuffer_Release(&(*buf)[j]);
- }
- PyMem_Del(*buf);
- total = 0;
- return total;
+ PyObject *item = PySequence_GetItem(seq, i);
+ if (item == NULL)
+ goto fail;
+ if (PyObject_GetBuffer(item, &(*buf)[i], type) == -1) {
+ Py_DECREF(item);
+ goto fail;
}
+ Py_DECREF(item);
(*iov)[i].iov_base = (*buf)[i].buf;
blen = (*buf)[i].len;
(*iov)[i].iov_len = blen;
total += blen;
}
return total;
+
+fail:
+ PyMem_Del(*iov);
+ for (j = 0; j < i; j++) {
+ PyBuffer_Release(&(*buf)[j]);
+ }
+ PyMem_Del(*buf);
+ return 0;
}
static void