]> granicus.if.org Git - python/commitdiff
Pull a NULL pointer check up to cover more cases in the function.
authorBrett Cannon <bcannon@gmail.com>
Tue, 4 May 2010 01:23:36 +0000 (01:23 +0000)
committerBrett Cannon <bcannon@gmail.com>
Tue, 4 May 2010 01:23:36 +0000 (01:23 +0000)
Found using Clang's static analyzer.

Objects/abstract.c

index 0b541ee74887a57d9a70c719a113297faf3f3c72..fddaed80b10dbe016da7ec9b7ef051dca359a920 100644 (file)
@@ -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;
 }