Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83fb073

Browse files
committed
Plug a memory leak in com_import_stmt(): the tuple created to hold the
"..." in "from M import ..." was never DECREFed. Leak reported by James Slaughter and nailed by Barry, who also provided an earlier version of this patch.
1 parent f8baad0 commit 83fb073

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Python/compile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2325,11 +2325,11 @@ static void
23252325
com_import_stmt(struct compiling *c, node *n)
23262326
{
23272327
int i;
2328-
PyObject *tup;
23292328
REQ(n, import_stmt);
23302329
/* 'import' dotted_name (',' dotted_name)* |
23312330
'from' dotted_name 'import' ('*' | NAME (',' NAME)*) */
23322331
if (STR(CHILD(n, 0))[0] == 'f') {
2332+
PyObject *tup;
23332333
/* 'from' dotted_name 'import' ... */
23342334
REQ(CHILD(n, 1), dotted_name);
23352335

@@ -2344,6 +2344,7 @@ com_import_stmt(struct compiling *c, node *n)
23442344
}
23452345
}
23462346
com_addoparg(c, LOAD_CONST, com_addconst(c, tup));
2347+
Py_DECREF(tup);
23472348
com_push(c, 1);
23482349
com_addopname(c, IMPORT_NAME, CHILD(n, 1));
23492350
if (TYPE(CHILD(n, 3)) == STAR)

0 commit comments

Comments
 (0)