summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorDaniel Stutzbach <daniel@stutzbachenterprises.com>2011-03-02 23:37:50 (GMT)
committerDaniel Stutzbach <daniel@stutzbachenterprises.com>2011-03-02 23:37:50 (GMT)
commit8eda5f7cd9007b6e60be6458f981b504c1442071 (patch)
tree4c400be3c3d9663d7c9f42046f2d8cce5406b07d /Objects/listobject.c
parent2f283c2c19f821dd5a0f2ad4a4da4c90fe583bb9 (diff)
downloadcpython-8eda5f7cd9007b6e60be6458f981b504c1442071.zip
cpython-8eda5f7cd9007b6e60be6458f981b504c1442071.tar.gz
cpython-8eda5f7cd9007b6e60be6458f981b504c1442071.tar.bz2
#11335: Fix memory leak when a sort key function throws an exception
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 9b2d36f..114749e 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -1957,6 +1957,8 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
if (keys[i] == NULL) {
for (i=i-1 ; i>=0 ; i--)
Py_DECREF(keys[i]);
+ if (keys != &ms.temparray[saved_ob_size+1])
+ PyMem_FREE(keys);
goto keyfunc_fail;
}
}