mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Pull a NULL pointer check up to cover more cases in the function.
Found using Clang's static analyzer.
This commit is contained in:
parent
a7f13ee3f5
commit
0d8a859a85
1 changed files with 4 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue