diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-09 11:33:53 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-09 11:33:53 (GMT) |
commit | 505ff755d704c73ac613d3e8fed02c79c6ae555a (patch) | |
tree | b9b0142cbeca125a1bcf0413e48d938d0cd390d3 /Modules | |
parent | e9c31470e1680b7c9b9ee83c378b891e90ac58ab (diff) | |
download | cpython-505ff755d704c73ac613d3e8fed02c79c6ae555a.zip cpython-505ff755d704c73ac613d3e8fed02c79c6ae555a.tar.gz cpython-505ff755d704c73ac613d3e8fed02c79c6ae555a.tar.bz2 |
Issue #20437: Fixed 21 potential bugs when deleting objects references.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 18 | ||||
-rw-r--r-- | Modules/_sqlite/cursor.c | 9 | ||||
-rw-r--r-- | Modules/posixmodule.c | 3 | ||||
-rw-r--r-- | Modules/pyexpat.c | 3 | ||||
-rw-r--r-- | Modules/readline.c | 5 | ||||
-rw-r--r-- | Modules/selectmodule.c | 3 | ||||
-rw-r--r-- | Modules/signalmodule.c | 9 | ||||
-rw-r--r-- | Modules/syslogmodule.c | 3 | ||||
-rw-r--r-- | Modules/zlibmodule.c | 3 |
9 files changed, 19 insertions, 37 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 7d0d258..48351be 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; @@ -2930,10 +2928,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)) { @@ -2976,10 +2972,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) diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 4999415..09c13d4 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -230,8 +230,7 @@ int pysqlite_build_row_cast_map(pysqlite_Cursor* self) if (converter != Py_None) { Py_DECREF(converter); } - Py_XDECREF(self->row_cast_map); - self->row_cast_map = NULL; + Py_CLEAR(self->row_cast_map); return -1; } @@ -443,8 +442,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* self->locked = 1; self->reset = 0; - Py_XDECREF(self->next_row); - self->next_row = NULL; + Py_CLEAR(self->next_row); if (multiple) { /* executemany() */ @@ -860,8 +858,7 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self) if (!self->next_row) { if (self->statement) { (void)pysqlite_statement_reset(self->statement); - Py_DECREF(self->statement); - self->statement = NULL; + Py_CLEAR(self->statement); } return NULL; } diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 4b077a0..e72fbcf 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -693,8 +693,7 @@ typedef struct { static void path_cleanup(path_t *path) { if (path->cleanup) { - Py_DECREF(path->cleanup); - path->cleanup = NULL; + Py_CLEAR(path->cleanup); } } diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 7e51d35..45680ae 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -314,8 +314,7 @@ call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args, } else { if (trace_frame(tstate, f, PyTrace_RETURN, res) < 0) { - Py_XDECREF(res); - res = NULL; + Py_CLEAR(res); } } #else diff --git a/Modules/readline.c b/Modules/readline.c index bcd34f7..8fac526 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -231,8 +231,7 @@ set_hook(const char *funcname, PyObject **hook_var, PyObject *args) if (!PyArg_ParseTuple(args, buf, &function)) return NULL; if (function == Py_None) { - Py_XDECREF(*hook_var); - *hook_var = NULL; + Py_CLEAR(*hook_var); } else if (PyCallable_Check(function)) { PyObject *tmp = *hook_var; @@ -827,7 +826,7 @@ on_completion_display_matches_hook(char **matches, (r != Py_None && PyLong_AsLong(r) == -1 && PyErr_Occurred())) { goto error; } - Py_XDECREF(r); r=NULL; + Py_CLEAR(r); if (0) { error: diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index c492224..952a091 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -74,8 +74,7 @@ reap_obj(pylist fd2obj[FD_SETSIZE + 1]) { int i; for (i = 0; i < FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) { - Py_XDECREF(fd2obj[i].obj); - fd2obj[i].obj = NULL; + Py_CLEAR(fd2obj[i].obj); } fd2obj[0].sentinel = -1; } diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index fbe1bb7..704c9f5 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1305,12 +1305,9 @@ finisignal(void) Py_XDECREF(func); } - Py_XDECREF(IntHandler); - IntHandler = NULL; - Py_XDECREF(DefaultHandler); - DefaultHandler = NULL; - Py_XDECREF(IgnoreHandler); - IgnoreHandler = NULL; + Py_CLEAR(IntHandler); + Py_CLEAR(DefaultHandler); + Py_CLEAR(IgnoreHandler); } diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c index 8b877cf..fc3f375 100644 --- a/Modules/syslogmodule.c +++ b/Modules/syslogmodule.c @@ -197,8 +197,7 @@ syslog_closelog(PyObject *self, PyObject *unused) { if (S_log_open) { closelog(); - Py_XDECREF(S_ident_o); - S_ident_o = NULL; + Py_CLEAR(S_ident_o); S_log_open = 0; } Py_INCREF(Py_None); diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index e718795..1d1072d 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -392,8 +392,7 @@ PyZlib_compressobj(PyObject *selfptr, PyObject *args, PyObject *kwargs) } error: - Py_XDECREF(self); - self = NULL; + Py_CLEAR(self); success: if (zdict.buf != NULL) PyBuffer_Release(&zdict); |