Issue #20437: Fixed 22 potential bugs when deleting objects references.

This commit is contained in:
Serhiy Storchaka 2014-02-09 13:46:20 +02:00
commit dfe98a102e
15 changed files with 34 additions and 63 deletions

View file

@ -3189,8 +3189,7 @@ fast_yield:
if (call_trace(tstate->c_tracefunc, tstate->c_traceobj,
tstate, f,
PyTrace_RETURN, retval)) {
Py_XDECREF(retval);
retval = NULL;
Py_CLEAR(retval);
why = WHY_EXCEPTION;
}
}
@ -3209,8 +3208,7 @@ fast_yield:
else if (call_trace(tstate->c_profilefunc, tstate->c_profileobj,
tstate, f,
PyTrace_RETURN, retval)) {
Py_XDECREF(retval);
retval = NULL;
Py_CLEAR(retval);
/* why = WHY_EXCEPTION; */
}
}
@ -3568,8 +3566,7 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,
if (co->co_flags & CO_GENERATOR) {
/* Don't need to keep the reference to f_back, it will be set
* when the generator is resumed. */
Py_XDECREF(f->f_back);
f->f_back = NULL;
Py_CLEAR(f->f_back);
PCALL(PCALL_GENERATOR);

View file

@ -349,8 +349,7 @@ _imp_release_lock_impl(PyModuleDef *module)
void
_PyImport_Fini(void)
{
Py_XDECREF(extensions);
extensions = NULL;
Py_CLEAR(extensions);
#ifdef WITH_THREAD
if (import_lock != NULL) {
PyThread_free_lock(import_lock);
@ -598,8 +597,7 @@ _PyImport_FixupExtensionObject(PyObject *mod, PyObject *name,
/* Somebody already imported the module,
likely under a different name.
XXX this should really not happen. */
Py_DECREF(def->m_base.m_copy);
def->m_base.m_copy = NULL;
Py_CLEAR(def->m_base.m_copy);
}
dict = PyModule_GetDict(mod);
if (dict == NULL)

View file

@ -430,8 +430,7 @@ trace_trampoline(PyObject *self, PyFrameObject *frame,
result = call_trampoline(callback, frame, what, arg);
if (result == NULL) {
PyEval_SetTrace(NULL, NULL);
Py_XDECREF(frame->f_trace);
frame->f_trace = NULL;
Py_CLEAR(frame->f_trace);
return -1;
}
if (result != Py_None) {