summaryrefslogtreecommitdiff
path: root/Include/internal
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-07-15 16:36:51 -0700
committerGitHub <noreply@github.com>2021-07-15 16:36:51 -0700
commit298ee657ab8170adf75a186c0414b7ca3baf1991 (patch)
tree17307435e9ee9871f12df489ea194d102f9dc13f /Include/internal
parent0b4704973dbef712d05bdd62349bb4244f545430 (diff)
downloadcpython-git-298ee657ab8170adf75a186c0414b7ca3baf1991.tar.gz
bpo-44184: Fix subtype_dealloc() for freed type (GH-26274)
Fix a crash at Python exit when a deallocator function removes the last strong reference to a heap type. Don't read type memory after calling basedealloc() since basedealloc() can deallocate the type and free its memory. _PyMem_IsPtrFreed() argument is now constant. (cherry picked from commit 615069eb08494d089bf24e43547fbc482ed699b8) Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Include/internal')
-rw-r--r--Include/internal/pycore_pymem.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/Include/internal/pycore_pymem.h b/Include/internal/pycore_pymem.h
index 3d925e2250..9bcb5f5efd 100644
--- a/Include/internal/pycore_pymem.h
+++ b/Include/internal/pycore_pymem.h
@@ -42,7 +42,7 @@ PyAPI_FUNC(int) _PyMem_SetDefaultAllocator(
fills newly allocated memory with CLEANBYTE (0xCD) and newly freed memory
with DEADBYTE (0xDD). Detect also "untouchable bytes" marked
with FORBIDDENBYTE (0xFD). */
-static inline int _PyMem_IsPtrFreed(void *ptr)
+static inline int _PyMem_IsPtrFreed(const void *ptr)
{
uintptr_t value = (uintptr_t)ptr;
#if SIZEOF_VOID_P == 8