Issue #18408: Fix bytearrayiter.partition()/rpartition(), handle

PyByteArray_FromStringAndSize() failure (ex: on memory allocation failure)
This commit is contained in:
Victor Stinner 2013-10-29 03:15:37 +01:00
parent 986e224d5a
commit cc64eb5b9f
1 changed files with 10 additions and 0 deletions

View File

@ -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);