diff options
author | Brett Cannon <bcannon@gmail.com> | 2010-05-04 01:23:36 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2010-05-04 01:23:36 (GMT) |
commit | 0d8a859a85c68b4dc3bd18072d0924b3ec544bdf (patch) | |
tree | f6ddb9b7633ac532fac8322c05046afbf7a5d875 /Objects/abstract.c | |
parent | a7f13ee3f5c9468abf6ce09b9a74d8a1b2782512 (diff) | |
download | cpython-0d8a859a85c68b4dc3bd18072d0924b3ec544bdf.zip cpython-0d8a859a85c68b4dc3bd18072d0924b3ec544bdf.tar.gz cpython-0d8a859a85c68b4dc3bd18072d0924b3ec544bdf.tar.bz2 |
Pull a NULL pointer check up to cover more cases in the function.
Found using Clang's static analyzer.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r-- | Objects/abstract.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 0b541ee..fddaed8 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; } |