diff options
author | Guido van Rossum <guido@python.org> | 1998-05-22 00:53:24 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-05-22 00:53:24 (GMT) |
commit | 1c4f45809994fcbebd3d43ec0c771b8900e205e8 (patch) | |
tree | d09177ebf29904f401b6ff951b6851923e7ead7f /Objects | |
parent | 7e33c6e89673afd4791f35aef6893a04b0218849 (diff) | |
download | cpython-1c4f45809994fcbebd3d43ec0c771b8900e205e8.zip cpython-1c4f45809994fcbebd3d43ec0c771b8900e205e8.tar.gz cpython-1c4f45809994fcbebd3d43ec0c771b8900e205e8.tar.bz2 |
In PyObject_IsTrue(), don't call function pointers that are NULL
(nb_nonzero, mp_length, sq_length).
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/object.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Objects/object.c b/Objects/object.c index 0588fea..964c5c5 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -469,11 +469,14 @@ PyObject_IsTrue(v) int res; if (v == Py_None) res = 0; - else if (v->ob_type->tp_as_number != NULL) + else if (v->ob_type->tp_as_number != NULL && + v->ob_type->tp_as_number->nb_nonzero != NULL) res = (*v->ob_type->tp_as_number->nb_nonzero)(v); - else if (v->ob_type->tp_as_mapping != NULL) + else if (v->ob_type->tp_as_mapping != NULL && + v->ob_type->tp_as_mapping->mp_length != NULL) res = (*v->ob_type->tp_as_mapping->mp_length)(v); - else if (v->ob_type->tp_as_sequence != NULL) + else if (v->ob_type->tp_as_sequence != NULL && + v->ob_type->tp_as_sequence->sq_length != NULL) res = (*v->ob_type->tp_as_sequence->sq_length)(v); else res = 1; |