[issue4460] The parameter of PyInt_AsSsize_t() is not checked to see if it is NULL

Mark Dickinson report at bugs.python.org
Sat Nov 29 18:17:21 CET 2008


Mark Dickinson <dickinsm at gmail.com> added the comment:

I'm confused.  I'm probably missing something, but why do you think such a 
check is necessary?  The code I'm seeing at around line 2766 is:

static Py_ssize_t
match_getindex(MatchObject* self, PyObject* index)
{
    Py_ssize_t i;

    if (PyInt_Check(index))
        return PyInt_AsSsize_t(index);

...

Is there any reason to expect that the index argument to match_getindex 
might be NULL?  Even if it were, surely it would be the PyInt_Check call 
that would be affected, not PyInt_AsSsize_t?

The usual pattern in Python C code is to check return values, but not 
incoming arguments.

----------
nosy: +marketdickinson

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4460>
_______________________________________


More information about the Python-bugs-list mailing list