diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-10-29 02:15:37 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-10-29 02:15:37 (GMT) |
commit | cc64eb5b9feaf610e75565600f6c6331e8fbe8d4 (patch) | |
tree | 99fef7d579ce989ec22bf01c6a58e2dd2c7a2c2a /Objects/stringlib | |
parent | 986e224d5a71342b683975ea0240315a8264616b (diff) | |
download | cpython-cc64eb5b9feaf610e75565600f6c6331e8fbe8d4.zip cpython-cc64eb5b9feaf610e75565600f6c6331e8fbe8d4.tar.gz cpython-cc64eb5b9feaf610e75565600f6c6331e8fbe8d4.tar.bz2 |
Issue #18408: Fix bytearrayiter.partition()/rpartition(), handle
PyByteArray_FromStringAndSize() failure (ex: on memory allocation failure)
Diffstat (limited to 'Objects/stringlib')
-rw-r--r-- | Objects/stringlib/partition.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/stringlib/partition.h b/Objects/stringlib/partition.h index 40cb512..ed32a6f 100644 --- a/Objects/stringlib/partition.h +++ b/Objects/stringlib/partition.h @@ -29,6 +29,11 @@ STRINGLIB(partition)(PyObject* str_obj, 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 @@ STRINGLIB(rpartition)(PyObject* str_obj, 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); |