]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38823: Fix refleak in _tracemalloc init error handling (GH-17235)
authorBrandt Bucher <brandtbucher@gmail.com>
Wed, 20 Nov 2019 10:00:31 +0000 (02:00 -0800)
committerVictor Stinner <vstinner@python.org>
Wed, 20 Nov 2019 10:00:31 +0000 (11:00 +0100)
Modules/_tracemalloc.c

index 211c6fbb8bcef8bef928f9b5c5f24eddf7c7eabc..70219721b51cd01b00acc43691e730ad044c0b21 100644 (file)
@@ -1656,8 +1656,10 @@ PyInit__tracemalloc(void)
     if (m == NULL)
         return NULL;
 
-    if (tracemalloc_init() < 0)
+    if (tracemalloc_init() < 0) {
+        Py_DECREF(m);
         return NULL;
+    }
 
     return m;
 }