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

Original file line number Diff line number Diff line change
@@ -2857,13 +2857,16 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
2857 2857 TARGET(IMPORT_STAR) {
2858 2858 PyObject *from = POP(), *locals;
2859 2859 int err;
2860 -if (PyFrame_FastToLocalsWithError(f) < 0)
2860 +if (PyFrame_FastToLocalsWithError(f) < 0) {
2861 +Py_DECREF(from);
2861 2862 goto error;
2863 + }
2862 2864
2863 2865 locals = f->f_locals;
2864 2866 if (locals == NULL) {
2865 2867 PyErr_SetString(PyExc_SystemError,
2866 2868 "no locals found during 'import *'");
2869 +Py_DECREF(from);
2867 2870 goto error;
2868 2871 }
2869 2872 err = import_all_from(locals, from);