Issue #14761: Fix potential leak on an error case in the import machinery.
diff --git a/Misc/ACKS b/Misc/ACKS
index 939e567..6d8b6dd 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -145,6 +145,7 @@
 Brett Cannon
 Mike Carlton
 Terry Carroll
+Damien Cassou
 Lorenzo M. Catucci
 Donn Cave
 Charles Cazabon
diff --git a/Misc/NEWS b/Misc/NEWS
index e02489b..b6bc463 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@
 Core and Builtins
 -----------------
 
+- Issue #14761: Fix potential leak on an error case in the import machinery.
+
 - Issue #14699: Fix calling the classmethod descriptor directly.
 
 - Issue #14433: Prevent msvcrt crash in interactive prompt when stdin
diff --git a/Python/import.c b/Python/import.c
index 1d3a485..598b7e0 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1293,7 +1293,7 @@
     FILE *fpc;
     char *buf;
     char *cpathname;
-    PyCodeObject *co;
+    PyCodeObject *co = NULL;
     PyObject *m;
 
     if (fstat(fileno(fp), &st) != 0) {
@@ -1350,6 +1350,7 @@
     return m;
 
 error_exit:
+    Py_XDECREF(co);
     PyMem_FREE(buf);
     return NULL;
 }