Skip to content

Commit 284fa08

Browse files
committed
Issue #14761: Fix potential leak on an error case in the import machinery.
1 parent 5ec0340 commit 284fa08

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ Tony Campbell
127127
Brett Cannon
128128
Mike Carlton
129129
Terry Carroll
130+
Damien Cassou
130131
Lorenzo M. Catucci
131132
Donn Cave
132133
Charles Cazabon

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ What's New in Python 2.7.4
99
Core and Builtins
1010
-----------------
1111

12+
- Issue #14761: Fix potential leak on an error case in the import machinery.
13+
1214
- Issue #14699: Fix calling the classmethod descriptor directly.
1315

1416
- Issue #11603 (again): Setting __repr__ to __str__ now raises a RuntimeError

Python/import.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ load_source_module(char *name, char *pathname, FILE *fp)
998998
FILE *fpc;
999999
char *buf;
10001000
char *cpathname;
1001-
PyCodeObject *co;
1001+
PyCodeObject *co = NULL;
10021002
PyObject *m;
10031003

10041004
if (fstat(fileno(fp), &st) != 0) {
@@ -1054,6 +1054,7 @@ load_source_module(char *name, char *pathname, FILE *fp)
10541054
return m;
10551055

10561056
error_exit:
1057+
Py_XDECREF(co);
10571058
PyMem_FREE(buf);
10581059
return NULL;
10591060
}

0 commit comments

Comments
 (0)