Skip to content

Commit

Permalink
bpo-33989: Ensure that ms.key_compare is always initialized in list_s…
Browse files Browse the repository at this point in the history
…ort_impl(). (GH-8710)
  • Loading branch information
ZackerySpytz authored and serhiy-storchaka committed Feb 21, 2019
1 parent ef1b88b commit ebc793d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
@@ -0,0 +1,2 @@
Fix a possible crash in :meth:`list.sort` when sorting objects with
``ob_type->tp_richcompare == NULL``. Patch by Zackery Spytz.
3 changes: 3 additions & 0 deletions Objects/listobject.c
Expand Up @@ -2334,6 +2334,9 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
else if ((ms.key_richcompare = key_type->tp_richcompare) != NULL) {
ms.key_compare = unsafe_object_compare;
}
else {
ms.key_compare = safe_object_compare;
}
}
else {
ms.key_compare = safe_object_compare;
Expand Down

0 comments on commit ebc793d

Please sign in to comment.