From: Brett Cannon Date: Tue, 4 May 2010 01:23:36 +0000 (+0000) Subject: Pull a NULL pointer check up to cover more cases in the function. X-Git-Tag: v2.7b2~96 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d8a859a85c68b4dc3bd18072d0924b3ec544bdf;p=python Pull a NULL pointer check up to cover more cases in the function. Found using Clang's static analyzer. --- diff --git a/Objects/abstract.c b/Objects/abstract.c index 0b541ee748..fddaed80b1 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1833,11 +1833,13 @@ PyNumber_ToBase(PyObject *n, int base) int PySequence_Check(PyObject *s) { - if (s && PyInstance_Check(s)) + if (s == NULL) + return 0; + if (PyInstance_Check(s)) return PyObject_HasAttrString(s, "__getitem__"); if (PyDict_Check(s)) return 0; - return s != NULL && s->ob_type->tp_as_sequence && + return s->ob_type->tp_as_sequence && s->ob_type->tp_as_sequence->sq_item != NULL; }