]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38823: Fix refleak in _tracemalloc init error handling (GH-17235)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 20 Nov 2019 10:26:48 +0000 (02:26 -0800)
committerGitHub <noreply@github.com>
Wed, 20 Nov 2019 10:26:48 +0000 (02:26 -0800)
(cherry picked from commit d51a363a4379385fdfe9c09a56324631465ede29)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
Modules/_tracemalloc.c

index ee32ac29b7eea225defb863bb5ac760f5d4e182b..cbcf55f817435f5e173da494e98a5f3c706a0af2 100644 (file)
@@ -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;
 }