mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
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.
This commit is contained in:
parent
f8baad0f17
commit
83fb073a03
1 changed files with 2 additions and 1 deletions
|
@ -2325,11 +2325,11 @@ static void
|
||||||
com_import_stmt(struct compiling *c, node *n)
|
com_import_stmt(struct compiling *c, node *n)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyObject *tup;
|
|
||||||
REQ(n, import_stmt);
|
REQ(n, import_stmt);
|
||||||
/* 'import' dotted_name (',' dotted_name)* |
|
/* 'import' dotted_name (',' dotted_name)* |
|
||||||
'from' dotted_name 'import' ('*' | NAME (',' NAME)*) */
|
'from' dotted_name 'import' ('*' | NAME (',' NAME)*) */
|
||||||
if (STR(CHILD(n, 0))[0] == 'f') {
|
if (STR(CHILD(n, 0))[0] == 'f') {
|
||||||
|
PyObject *tup;
|
||||||
/* 'from' dotted_name 'import' ... */
|
/* 'from' dotted_name 'import' ... */
|
||||||
REQ(CHILD(n, 1), dotted_name);
|
REQ(CHILD(n, 1), dotted_name);
|
||||||
|
|
||||||
|
@ -2344,6 +2344,7 @@ com_import_stmt(struct compiling *c, node *n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
com_addoparg(c, LOAD_CONST, com_addconst(c, tup));
|
com_addoparg(c, LOAD_CONST, com_addconst(c, tup));
|
||||||
|
Py_DECREF(tup);
|
||||||
com_push(c, 1);
|
com_push(c, 1);
|
||||||
com_addopname(c, IMPORT_NAME, CHILD(n, 1));
|
com_addopname(c, IMPORT_NAME, CHILD(n, 1));
|
||||||
if (TYPE(CHILD(n, 3)) == STAR)
|
if (TYPE(CHILD(n, 3)) == STAR)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue