From: Tim Peters Date: Fri, 6 May 2022 04:14:09 +0000 (-0500) Subject: Issues/88027: A potential double free in list_sort_impl (#92367) X-Git-Tag: v3.11.0b1~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9652900969df77b1ac245595419431df19296af9;p=thirdparty%2FPython%2Fcpython.git Issues/88027: A potential double free in list_sort_impl (#92367) merge_freemem(): set keys to NULL do it's harmless to call this again. --- diff --git a/Objects/listobject.c b/Objects/listobject.c index 972f99582163..b50623ed73d9 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -1573,8 +1573,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.