]> 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:54 +0000 (02:26 -0800)
committerGitHub <noreply@github.com>
Wed, 20 Nov 2019 10:26:54 +0000 (02:26 -0800)
(cherry picked from commit d51a363a4379385fdfe9c09a56324631465ede29)

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

index 7f19c5598120e4ec64455442aad6560102aeb9fd..1fe72a8a4627b5db58fd79fd04546c92bf8ec426 100644 (file)
@@ -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;
 }