]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36356: Fix memory leak in _asynciomodule.c (GH-16598)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 7 Oct 2019 16:38:00 +0000 (09:38 -0700)
committerGitHub <noreply@github.com>
Mon, 7 Oct 2019 16:38:00 +0000 (09:38 -0700)
(cherry picked from commit 321def805abc5b7c92c7e90ca90cb2434fdab855)

Co-authored-by: Ben Harper <btharper1221@gmail.com>
Modules/_asynciomodule.c

index 8eb480fb77eaaf71a6d9cacd18940dcedb8b6507..5261ed3d4c3d06977aa16bb824a3536ff0d48f34 100644 (file)
@@ -33,6 +33,7 @@ static PyObject *asyncio_task_repr_info_func;
 static PyObject *asyncio_InvalidStateError;
 static PyObject *asyncio_CancelledError;
 static PyObject *context_kwname;
+static int module_initialized;
 
 static PyObject *cached_running_holder;
 static volatile uint64_t cached_running_holder_tsid;
@@ -3254,6 +3255,12 @@ module_init(void)
     if (asyncio_mod == NULL) {
         goto fail;
     }
+    if (module_initialized != 0) {
+        return 0;
+    } 
+    else {
+        module_initialized = 1;
+    }
 
     current_tasks = PyDict_New();
     if (current_tasks == NULL) {