https://github.com/python/cpython/commit/daf7a082b20e59a0518cda1500add42c36a... commit: daf7a082b20e59a0518cda1500add42c36ab058f branch: 3.8 author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> committer: GitHub <noreply@github.com> date: 2019-11-20T02:26:48-08:00 summary: bpo-38823: Fix refleak in _tracemalloc init error handling (GH-17235) (cherry picked from commit d51a363a4379385fdfe9c09a56324631465ede29) Co-authored-by: Brandt Bucher <brandtbucher@gmail.com> files: M Modules/_tracemalloc.c diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index ee32ac29b7eea..cbcf55f817435 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; }