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

Skip to content

Commit b39903b

Browse files
committed
symtable_cellvar_offsets(): This leaked references to little integers
in normal cases, and also in error cases. Bugfix candidate.
1 parent cf76be0 commit b39903b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Python/compile.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4496,7 +4496,8 @@ static int
44964496
symtable_cellvar_offsets(PyObject **cellvars, int argcount,
44974497
PyObject *varnames, int flags)
44984498
{
4499-
PyObject *v, *w, *d, *list = NULL;
4499+
PyObject *v = NULL;
4500+
PyObject *w, *d, *list = NULL;
45004501
int i, pos;
45014502

45024503
if (flags & CO_VARARGS)
@@ -4530,6 +4531,7 @@ symtable_cellvar_offsets(PyObject **cellvars, int argcount,
45304531
goto fail;
45314532
if (PyDict_DelItem(*cellvars, PyList_GET_ITEM(list, i)) < 0)
45324533
goto fail;
4534+
Py_DECREF(v);
45334535
}
45344536
pos = 0;
45354537
i = PyList_GET_SIZE(list);
@@ -4538,6 +4540,7 @@ symtable_cellvar_offsets(PyObject **cellvars, int argcount,
45384540
w = PyInt_FromLong(i++); /* don't care about the old key */
45394541
if (PyDict_SetItem(d, v, w) < 0) {
45404542
Py_DECREF(w);
4543+
v = NULL;
45414544
goto fail;
45424545
}
45434546
Py_DECREF(w);
@@ -4547,6 +4550,7 @@ symtable_cellvar_offsets(PyObject **cellvars, int argcount,
45474550
return 1;
45484551
fail:
45494552
Py_DECREF(d);
4553+
Py_XDECREF(v);
45504554
return -1;
45514555
}
45524556

0 commit comments

Comments
 (0)