summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
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 /Modules/_ctypes
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 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/_ctypes.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 820a606..97ae798 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -159,10 +159,8 @@ _DictRemover_call(PyObject *myself, PyObject *args, PyObject *kw)
if (-1 == PyDict_DelItem(self->dict, self->key))
/* XXX Error context */
PyErr_WriteUnraisable(Py_None);
- Py_DECREF(self->key);
- self->key = NULL;
- Py_DECREF(self->dict);
- self->dict = NULL;
+ Py_CLEAR(self->key);
+ Py_CLEAR(self->dict);
}
Py_INCREF(Py_None);
return Py_None;
@@ -2934,10 +2932,8 @@ static int
PyCFuncPtr_set_restype(PyCFuncPtrObject *self, PyObject *ob)
{
if (ob == NULL) {
- Py_XDECREF(self->restype);
- self->restype = NULL;
- Py_XDECREF(self->checker);
- self->checker = NULL;
+ Py_CLEAR(self->restype);
+ Py_CLEAR(self->checker);
return 0;
}
if (ob != Py_None && !PyType_stgdict(ob) && !PyCallable_Check(ob)) {
@@ -2980,10 +2976,8 @@ PyCFuncPtr_set_argtypes(PyCFuncPtrObject *self, PyObject *ob)
PyObject *converters;
if (ob == NULL || ob == Py_None) {
- Py_XDECREF(self->converters);
- self->converters = NULL;
- Py_XDECREF(self->argtypes);
- self->argtypes = NULL;
+ Py_CLEAR(self->converters);
+ Py_CLEAR(self->argtypes);
} else {
converters = converters_from_argtypes(ob);
if (!converters)