From: Andrew M. Kuchling Date: Mon, 9 Oct 2006 18:19:01 +0000 (+0000) Subject: [Backport r42951 | guido.van.rossum] X-Git-Tag: v2.4.4c1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0235ae1a9a723e3465e10b91333c2e5e2a30618;p=thirdparty%2FPython%2Fcpython.git [Backport r42951 | guido.van.rossum] Fix three nits found by Coverity, adding null checks and comments. [This commit only makes two changes. One change in the original patch is just adding a comment, and another adds a 'base != NULL' check to silence Coverity, but a comment adds that that base is never going to be NULL. I didn't backport that change. --amk] --- diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 0bed8cc692ad..295634c0a831 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3712,7 +3712,9 @@ hackcheck(PyObject *self, setattrofunc func, char *what) PyTypeObject *type = self->ob_type; while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE) type = type->tp_base; - if (type->tp_setattro != func) { + /* If type is NULL now, this is a really weird type. + In the spirit of backwards compatibility (?), just shut up. */ + if (type && type->tp_setattro != func) { PyErr_Format(PyExc_TypeError, "can't apply this %s to %s object", what, @@ -3927,7 +3929,9 @@ tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds) staticbase = subtype; while (staticbase && (staticbase->tp_flags & Py_TPFLAGS_HEAPTYPE)) staticbase = staticbase->tp_base; - if (staticbase->tp_new != type->tp_new) { + /* If staticbase is NULL now, this is a really weird type. + In the spirit of backwards compatibility (?), just shut up. */ + if (staticbase && staticbase->tp_new != type->tp_new) { PyErr_Format(PyExc_TypeError, "%s.__new__(%s) is not safe, use %s.__new__()", type->tp_name,