diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index ee32ac29b7e..cbcf55f8174 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -1637,8 +1637,10 @@ PyInit__tracemalloc(void) if (m == NULL) return NULL; - if (tracemalloc_init() < 0) + if (tracemalloc_init() < 0) { + Py_DECREF(m); return NULL; + } return m; }