summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-02-09 11:46:20 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-02-09 11:46:20 (GMT)
commitdfe98a102ec8723d750f78ecda08a7adb9360eb1 (patch)
treef8aea8fb3d74be18ed67a2f4e0a355ad9beb42d8 /Python
parent2623c8c23cead505a78ec416072223552e94727e (diff)
parent505ff755d704c73ac613d3e8fed02c79c6ae555a (diff)
downloadcpython-dfe98a102ec8723d750f78ecda08a7adb9360eb1.zip
cpython-dfe98a102ec8723d750f78ecda08a7adb9360eb1.tar.gz
cpython-dfe98a102ec8723d750f78ecda08a7adb9360eb1.tar.bz2
Issue #20437: Fixed 22 potential bugs when deleting objects references.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c9
-rw-r--r--Python/import.c6
-rw-r--r--Python/sysmodule.c3
3 files changed, 6 insertions, 12 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 34c52b0..5db88be 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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);
diff --git a/Python/import.c b/Python/import.c
index 001d745..d0115e4 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -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)
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 976d5a0..9ec3bfa 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -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) {