[Python-checkins] cpython (3.2): Issue #14761: Fix potential leak on an error case in the import machinery.

antoine.pitrou python-checkins at python.org
Wed May 9 13:30:24 CEST 2012


http://hg.python.org/cpython/rev/9de4d85e4197
changeset:   76847:9de4d85e4197
branch:      3.2
parent:      76842:597826f7f6f5
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed May 09 13:24:31 2012 +0200
summary:
  Issue #14761: Fix potential leak on an error case in the import machinery.

files:
  Misc/ACKS       |  1 +
  Misc/NEWS       |  2 ++
  Python/import.c |  3 ++-
  3 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Misc/ACKS b/Misc/ACKS
--- 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
--- 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
--- 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;
 }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list