diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-04-23 17:04:36 -0400 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-04-23 17:04:36 -0400 |
commit | 0823ffb2fb16aa29cefd4c1b91edd82d9814e46a (patch) | |
tree | d9e0c15afd1ae9ab0024317a2195b6636f6249d7 | |
parent | 893cce921cf99bac08f14fb92426bd8e191e9c79 (diff) | |
download | cpython-git-0823ffb2fb16aa29cefd4c1b91edd82d9814e46a.tar.gz |
properly handle malloc failure (closes #24044)
Patch by Christian Heimes.
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Objects/listobject.c | 6 |
2 files changed, 7 insertions, 2 deletions
@@ -10,6 +10,9 @@ What's New in Python 3.2.7? 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 --git a/Objects/listobject.c b/Objects/listobject.c index b9ef0d0287..3642b39dd1 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -1924,8 +1924,10 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds) 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++) { |