]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-131719: add NULL pointer check to `_PyMem_FreeDelayed` (gh-131720) (gh...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 25 Mar 2025 15:15:26 +0000 (16:15 +0100)
committerGitHub <noreply@github.com>
Tue, 25 Mar 2025 15:15:26 +0000 (15:15 +0000)
(cherry picked from commit 0a91456ad14bb598646f50bf8f034e8887c0c468)

Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
Misc/NEWS.d/next/Core_and_Builtins/2025-03-25-13-58-25.gh-issue-131719.zKv98a.rst [new file with mode: 0644]
Objects/obmalloc.c

diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-03-25-13-58-25.gh-issue-131719.zKv98a.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-03-25-13-58-25.gh-issue-131719.zKv98a.rst
new file mode 100644 (file)
index 0000000..ad91755
--- /dev/null
@@ -0,0 +1 @@
+Fix missing NULL check in ``_PyMem_FreeDelayed`` in :term:`free-threaded <free threading>` build.
index 4b830f5bb63c697294ed2201815a22249614d2c6..6f23639645000b1370898612cfd98ea716fbb452 100644 (file)
@@ -1160,7 +1160,9 @@ void
 _PyMem_FreeDelayed(void *ptr)
 {
     assert(!((uintptr_t)ptr & 0x01));
-    free_delayed((uintptr_t)ptr);
+    if (ptr != NULL) {
+        free_delayed((uintptr_t)ptr);
+    }
 }
 
 void