Commits

Antoine Pitrou  committed a775fc2

Issue #14761: Fix potential leak on an error case in the import machinery.

  • Participants
  • Parent commits 5683ca6
  • Branches 2.7

Comments (0)

Files changed (3)

 Brett Cannon
 Mike Carlton
 Terry Carroll
+Damien Cassou
 Lorenzo M. Catucci
 Donn Cave
 Charles Cazabon
 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 #11603 (again): Setting __repr__ to __str__ now raises a RuntimeError

File Python/import.c

     FILE *fpc;
     char *buf;
     char *cpathname;
-    PyCodeObject *co;
+    PyCodeObject *co = NULL;
     PyObject *m;
 
     if (fstat(fileno(fp), &st) != 0) {
     return m;
 
 error_exit:
+    Py_XDECREF(co);
     PyMem_FREE(buf);
     return NULL;
 }