[Python-checkins] Issues/88027: A potential double free in list_sort_impl (GH-92367)

miss-islington webhook-mailer at python.org
Fri May 6 00:38:28 EDT 2022


https://github.com/python/cpython/commit/0eef443f0142b8cee705a22d0d1c9df17be94f69
commit: 0eef443f0142b8cee705a22d0d1c9df17be94f69
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-05-05T21:38:14-07:00
summary:

Issues/88027: A potential double free in list_sort_impl (GH-92367)


merge_freemem(): set keys to NULL do it's harmless to call this again.
(cherry picked from commit 9652900969df77b1ac245595419431df19296af9)

Co-authored-by: Tim Peters <tim.peters at gmail.com>

files:
M Objects/listobject.c

diff --git a/Objects/listobject.c b/Objects/listobject.c
index 533ee7436d311..d3bc5766df7a0 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -1548,8 +1548,10 @@ static void
 merge_freemem(MergeState *ms)
 {
     assert(ms != NULL);
-    if (ms->a.keys != ms->temparray)
+    if (ms->a.keys != ms->temparray) {
         PyMem_Free(ms->a.keys);
+        ms->a.keys = NULL;
+    }
 }
 
 /* Ensure enough temp memory for 'need' array slots is available.



More information about the Python-checkins mailing list