]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport: SF bug #1331563 ] string_subscript doesn't check for failed PyMem_Malloc.
authorNeal Norwitz <nnorwitz@gmail.com>
Thu, 20 Oct 2005 04:16:45 +0000 (04:16 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Thu, 20 Oct 2005 04:16:45 +0000 (04:16 +0000)
Objects/stringobject.c

index b8e5f41342c2da19f8fed2a787bd6a97019b274d..e7b6e69b0da0b0eb379fa486bcbf14044f1bc582 100644 (file)
@@ -1184,6 +1184,8 @@ string_subscript(PyStringObject* self, PyObject* item)
                else {
                        source_buf = PyString_AsString((PyObject*)self);
                        result_buf = PyMem_Malloc(slicelength);
+                       if (result_buf == NULL)
+                               return PyErr_NoMemory();
 
                        for (cur = start, i = 0; i < slicelength; 
                             cur += step, i++) {