Fix refleak: PyObject_GetItem returns a new reference, not a borrowed one like PyDict_GetItem.

This commit is contained in:
Antoine Pitrou 2012-04-19 18:21:04 +02:00
parent aa2efcb0bc
commit bf35c156b4
1 changed files with 3 additions and 3 deletions

View File

@ -1940,6 +1940,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
"__build_class__ not found"); "__build_class__ not found");
break; break;
} }
Py_INCREF(x);
} }
else { else {
PyObject *build_class_str = _PyUnicode_FromId(&PyId___build_class__); PyObject *build_class_str = _PyUnicode_FromId(&PyId___build_class__);
@ -1953,7 +1954,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
break; break;
} }
} }
Py_INCREF(x);
PUSH(x); PUSH(x);
break; break;
} }
@ -2092,6 +2092,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
} }
if (x == NULL) { if (x == NULL) {
x = PyDict_GetItem(f->f_globals, w); x = PyDict_GetItem(f->f_globals, w);
Py_XINCREF(x);
if (x == NULL) { if (x == NULL) {
if (PyDict_CheckExact(f->f_builtins)) { if (PyDict_CheckExact(f->f_builtins)) {
x = PyDict_GetItem(f->f_builtins, w); x = PyDict_GetItem(f->f_builtins, w);
@ -2101,6 +2102,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
NAME_ERROR_MSG, w); NAME_ERROR_MSG, w);
break; break;
} }
Py_INCREF(x);
} }
else { else {
x = PyObject_GetItem(f->f_builtins, w); x = PyObject_GetItem(f->f_builtins, w);
@ -2113,7 +2115,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
} }
} }
} }
Py_INCREF(x);
} }
PUSH(x); PUSH(x);
DISPATCH(); DISPATCH();
@ -2186,7 +2187,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
break; break;
} }
} }
Py_INCREF(x);
PUSH(x); PUSH(x);
DISPATCH(); DISPATCH();