From: Antoine Pitrou Date: Wed, 9 May 2012 11:24:31 +0000 (+0200) Subject: Issue #14761: Fix potential leak on an error case in the import machinery. X-Git-Tag: v2.7.4rc1~841 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=284fa08eb783a48f98eabda25aaaebefb5937cce;p=thirdparty%2FPython%2Fcpython.git Issue #14761: Fix potential leak on an error case in the import machinery. --- diff --git a/Misc/ACKS b/Misc/ACKS index bf686f49ddff..2fb33823edb2 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -127,6 +127,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 1ac29ff758ac..29e6dadaa529 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -9,6 +9,8 @@ What's New in Python 2.7.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 #11603 (again): Setting __repr__ to __str__ now raises a RuntimeError diff --git a/Python/import.c b/Python/import.c index 108a1e1b0741..2f11e756c92c 100644 --- a/Python/import.c +++ b/Python/import.c @@ -998,7 +998,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) { @@ -1054,6 +1054,7 @@ load_source_module(char *name, char *pathname, FILE *fp) return m; error_exit: + Py_XDECREF(co); PyMem_FREE(buf); return NULL; }