From d576c711a510204604f707e1cbf773b4a39f21a3 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 9 May 2012 13:24:31 +0200 Subject: [PATCH] Issue #14761: Fix potential leak on an error case in the import machinery. --- Misc/ACKS | 1 + Misc/NEWS | 2 ++ Python/import.c | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Misc/ACKS b/Misc/ACKS index 939e567441a..6d8b6dddd29 100644 --- 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 diff --git a/Misc/NEWS b/Misc/NEWS index e02489bcf05..b6bc463a5d2 100644 --- 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 diff --git a/Python/import.c b/Python/import.c index 1d3a4859dae..598b7e09d90 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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; }