summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/listobject.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 3d2e09f..85e55d0 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -28,6 +28,9 @@ Core and Builtins
- Issue #23629: Fix the default __sizeof__ implementation for variable-sized
objects.
+- Issue #24044: Fix possible null pointer dereference in list.sort in out of
+ memory conditions.
+
Library
-------
diff --git a/Objects/listobject.c b/Objects/listobject.c
index b6c1d78..19967ca 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -1961,8 +1961,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++) {