Skip to content

Commit 491ec30

Browse files
add defensive checks to PyTraceMalloc_Untrack
1 parent 24ea805 commit 491ec30

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Python/tracemalloc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,12 @@ PyTraceMalloc_Untrack(unsigned int domain, uintptr_t ptr)
12361236
}
12371237

12381238
TABLES_LOCK();
1239+
// Check again now that we hold the lock
1240+
if (!tracemalloc_config.tracing) {
1241+
TABLES_UNLOCK();
1242+
/* tracemalloc is not tracing: do nothing */
1243+
return -2;
1244+
}
12391245
tracemalloc_remove_trace_unlocked(domain, ptr);
12401246
TABLES_UNLOCK();
12411247
return 0;

0 commit comments

Comments
 (0)