changeset: 95786:91096d27c802 branch: 3.2 parent: 94677:29316b605ae4 user: Benjamin Peterson date: Thu Apr 23 17:04:36 2015 -0400 files: Misc/NEWS Objects/listobject.c description: properly handle malloc failure (closes #24044) Patch by Christian Heimes. diff -r 29316b605ae4 -r 91096d27c802 Misc/NEWS --- a/Misc/NEWS Wed Feb 18 08:52:46 2015 -0500 +++ b/Misc/NEWS Thu Apr 23 17:04:36 2015 -0400 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #24044: Fix possible null pointer dereference in list.sort in out of + memory conditions. + - Issue #23055: Fixed a buffer overflow in PyUnicode_FromFormatV. Analysis and fix by Guido Vranken. diff -r 29316b605ae4 -r 91096d27c802 Objects/listobject.c --- a/Objects/listobject.c Wed Feb 18 08:52:46 2015 -0500 +++ b/Objects/listobject.c Thu Apr 23 17:04:36 2015 -0400 @@ -1924,8 +1924,10 @@ keys = &ms.temparray[saved_ob_size+1]; else { keys = PyMem_MALLOC(sizeof(PyObject *) * saved_ob_size); - if (keys == NULL) - return NULL; + if (keys == NULL) { + PyErr_NoMemory(); + goto keyfunc_fail; + } } for (i = 0; i < saved_ob_size ; i++) {