[Python-checkins] bpo-38823: Fix refleak in _tracemalloc init error handling (GH-17235)

Miss Islington (bot) webhook-mailer at python.org
Wed Nov 20 05:27:08 EST 2019


https://github.com/python/cpython/commit/1d7245c3e0cfe4508855c5025b25d8894155ecc5
commit: 1d7245c3e0cfe4508855c5025b25d8894155ecc5
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-11-20T02:26:54-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 at gmail.com>

files:
M Modules/_tracemalloc.c

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



More information about the Python-checkins mailing list