Patch #708604: Check more function results. Will backport to 2.2.

This commit is contained in:
Martin v. Löwis 2003-05-03 10:53:08 +00:00
parent bcd93962ce
commit cd12bfc142
2 changed files with 45 additions and 8 deletions

View file

@ -473,6 +473,8 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
/* Special case "a[i:j] = a" -- copy b first */
int ret;
v = list_slice(b, 0, n);
if (v == NULL)
return -1;
ret = list_ass_slice(a, ilow, ihigh, v);
Py_DECREF(v);
return ret;
@ -488,8 +490,13 @@ list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
ihigh = a->ob_size;
item = a->ob_item;
d = n - (ihigh-ilow);
if (ihigh > ilow)
if (ihigh > ilow) {
p = recycle = PyMem_NEW(PyObject *, (ihigh-ilow));
if (recycle == NULL) {
PyErr_NoMemory();
return -1;
}
}
else
p = recycle = NULL;
if (d <= 0) { /* Delete -d items; recycle ihigh-ilow items */