[Python-checkins] cpython: Issue #18408: Fix bytearrayiter.partition()/rpartition(), handle
victor.stinner
python-checkins at python.org
Tue Oct 29 03:51:23 CET 2013
http://hg.python.org/cpython/rev/9d9371d4ff7b
changeset: 86721:9d9371d4ff7b
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Oct 29 03:15:37 2013 +0100
summary:
Issue #18408: Fix bytearrayiter.partition()/rpartition(), handle
PyByteArray_FromStringAndSize() failure (ex: on memory allocation failure)
files:
Objects/stringlib/partition.h | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/Objects/stringlib/partition.h b/Objects/stringlib/partition.h
--- a/Objects/stringlib/partition.h
+++ b/Objects/stringlib/partition.h
@@ -29,6 +29,11 @@
PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len));
PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0));
PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0));
+
+ if (PyErr_Occurred()) {
+ Py_DECREF(out);
+ return NULL;
+ }
#else
Py_INCREF(str_obj);
PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj);
@@ -79,6 +84,11 @@
PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0));
PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0));
PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len));
+
+ if (PyErr_Occurred()) {
+ Py_DECREF(out);
+ return NULL;
+ }
#else
Py_INCREF(STRINGLIB_EMPTY);
PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list