]> granicus.if.org Git - python/commitdiff
Prevent crash if alloc of garbage fails. Found by Typo.pl.
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 28 Oct 2006 21:20:12 +0000 (21:20 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 28 Oct 2006 21:20:12 +0000 (21:20 +0000)
Will backport.

Objects/listobject.c

index bf4466a1a2d21bac0aaac928b1e4c07e289900e3..a1ac2cba1017fd6e9785c38e646dfe6862f8661b 100644 (file)
@@ -2608,6 +2608,11 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
 
                        garbage = (PyObject**)
                                PyMem_MALLOC(slicelength*sizeof(PyObject*));
+                       if (!garbage) {
+                               Py_DECREF(seq);
+                               PyErr_NoMemory();
+                               return -1;
+                       }
 
                        selfitems = self->ob_item;
                        seqitems = PySequence_Fast_ITEMS(seq);