summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-02-09 11:33:53 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-02-09 11:33:53 (GMT)
commit505ff755d704c73ac613d3e8fed02c79c6ae555a (patch)
treeb9b0142cbeca125a1bcf0413e48d938d0cd390d3 /Objects
parente9c31470e1680b7c9b9ee83c378b891e90ac58ab (diff)
downloadcpython-505ff755d704c73ac613d3e8fed02c79c6ae555a.zip
cpython-505ff755d704c73ac613d3e8fed02c79c6ae555a.tar.gz
cpython-505ff755d704c73ac613d3e8fed02c79c6ae555a.tar.bz2
Issue #20437: Fixed 21 potential bugs when deleting objects references.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/frameobject.c3
-rw-r--r--Objects/tupleobject.c6
-rw-r--r--Objects/unicodeobject.c12
3 files changed, 7 insertions, 14 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 808e595..b312130 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -952,8 +952,7 @@ void
PyFrame_Fini(void)
{
(void)PyFrame_ClearFreeList();
- Py_XDECREF(builtin_object);
- builtin_object = NULL;
+ Py_CLEAR(builtin_object);
}
/* Print summary info about the state of the optimized allocator */
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index ec3f91b..123df8c 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -866,8 +866,7 @@ _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
_Py_ForgetReference((PyObject *) v);
/* DECREF items deleted by shrinkage */
for (i = newsize; i < oldsize; i++) {
- Py_XDECREF(v->ob_item[i]);
- v->ob_item[i] = NULL;
+ Py_CLEAR(v->ob_item[i]);
}
sv = PyObject_GC_Resize(PyTupleObject, v, newsize);
if (sv == NULL) {
@@ -913,8 +912,7 @@ PyTuple_Fini(void)
#if PyTuple_MAXSAVESIZE > 0
/* empty tuples are used all over the place and applications may
* rely on the fact that an empty tuple is a singleton. */
- Py_XDECREF(free_list[0]);
- free_list[0] = NULL;
+ Py_CLEAR(free_list[0]);
(void)PyTuple_ClearFreeList();
#endif
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index beafaa4..e1ff999 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1846,8 +1846,7 @@ _PyUnicode_ClearStaticStrings()
{
_Py_Identifier *tmp, *s = static_strings;
while (s) {
- Py_DECREF(s->object);
- s->object = NULL;
+ Py_CLEAR(s->object);
tmp = s->next;
s->next = NULL;
s = tmp;
@@ -4082,8 +4081,7 @@ make_decode_exception(PyObject **exceptionObject,
return;
onError:
- Py_DECREF(*exceptionObject);
- *exceptionObject = NULL;
+ Py_CLEAR(*exceptionObject);
}
/* error handling callback helper:
@@ -6224,8 +6222,7 @@ make_encode_exception(PyObject **exceptionObject,
goto onError;
return;
onError:
- Py_DECREF(*exceptionObject);
- *exceptionObject = NULL;
+ Py_CLEAR(*exceptionObject);
}
}
@@ -8225,8 +8222,7 @@ make_translate_exception(PyObject **exceptionObject,
goto onError;
return;
onError:
- Py_DECREF(*exceptionObject);
- *exceptionObject = NULL;
+ Py_CLEAR(*exceptionObject);
}
}