]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131719: add NULL pointer check to `_PyMem_FreeDelayed` (gh-131720)
authorTomasz Pytel <tompytel@gmail.com>
Tue, 25 Mar 2025 14:49:18 +0000 (10:49 -0400)
committerGitHub <noreply@github.com>
Tue, 25 Mar 2025 14:49:18 +0000 (10:49 -0400)
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 1285398142933a7b2cfbb1d5f767a53ff02abed4..b209808da902daa9f732cec20505f9b2048c0ed1 100644 (file)
@@ -1215,7 +1215,9 @@ void
 _PyMem_FreeDelayed(void *ptr)
 {
     assert(!((uintptr_t)ptr & 0x01));
-    free_delayed((uintptr_t)ptr);
+    if (ptr != NULL) {
+        free_delayed((uintptr_t)ptr);
+    }
 }
 
 #ifdef Py_GIL_DISABLED