bpo-29655: Fixed possible reference leaks in import *. (#301) · python/cpython@160edb4 (original) (raw)

Original file line number Diff line number Diff line change
@@ -2810,13 +2810,16 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
2810 2810 TARGET(IMPORT_STAR) {
2811 2811 PyObject *from = POP(), *locals;
2812 2812 int err;
2813 -if (PyFrame_FastToLocalsWithError(f) < 0)
2813 +if (PyFrame_FastToLocalsWithError(f) < 0) {
2814 +Py_DECREF(from);
2814 2815 goto error;
2816 + }
2815 2817
2816 2818 locals = f->f_locals;
2817 2819 if (locals == NULL) {
2818 2820 PyErr_SetString(PyExc_SystemError,
2819 2821 "no locals found during 'import *'");
2822 +Py_DECREF(from);
2820 2823 goto error;
2821 2824 }
2822 2825 err = import_all_from(locals, from);