Issue #14761: Fix potential leak on an error case in the import machinery.
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 9 May 2012 11:24:31 +0000 (13:24 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 9 May 2012 11:24:31 +0000 (13:24 +0200)
Misc/ACKS
Misc/NEWS
Python/import.c

index 939e567441aaf4fd35e45f85bbdedbb2fc438732..6d8b6dddd293f26f6f1567c2a5cffdaf5d899fbd 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -145,6 +145,7 @@ Tony Campbell
 Brett Cannon
 Mike Carlton
 Terry Carroll
+Damien Cassou
 Lorenzo M. Catucci
 Donn Cave
 Charles Cazabon
index e02489bcf055bd95b4af4e0f96d784f796656153..b6bc463a5d2fa91aa41594bb5dc7bbda915e2188 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.2.4
 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
index 1d3a4859dae8a0cf2ce57280deb33b84f5a81401..598b7e09d909ab26c4e52ddf7eec93a9f341dabb 100644 (file)
@@ -1293,7 +1293,7 @@ load_source_module(char *name, char *pathname, FILE *fp)
     FILE *fpc;
     char *buf;
     char *cpathname;
-    PyCodeObject *co;
+    PyCodeObject *co = NULL;
     PyObject *m;
 
     if (fstat(fileno(fp), &st) != 0) {
@@ -1350,6 +1350,7 @@ load_source_module(char *name, char *pathname, FILE *fp)
     return m;
 
 error_exit:
+    Py_XDECREF(co);
     PyMem_FREE(buf);
     return NULL;
 }