[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] BUG: UintFromObj from base.c does not check for errors



Hi,
I'm not too familiar with the Python/C api, but it looks like that would fix it.

Thanks,
- Devan.

On Mon, Sep 1, 2008 at 8:10 PM, René Dudfield <renesd@xxxxxxxxx> wrote:
> Thanks.
>
> Does the change below look ok?   (non-compiled, non-tested code)
>
> I'm without internet at home for a week or so...  so if someone else
> can look over it, test it, and commit it that'd be cool?
>
> from src/base.c
>
> static int UintFromObj (PyObject* obj, Uint32* val) {
>    PyObject* intobj;
>    int tmp_val;
>
>    if (PyNumber_Check (obj)) {
>
>        if (!(intobj = PyNumber_Int (obj)))
>            return 0;
>
>        tmp_val = PyInt_AsLong (obj);
>        if (tmp_val == -1 && PyErr_Occurred ()) {
>            PyErr_Clear ();
>            Py_DECREF (intobj);
>            return 0;
>        }
>        *val = (Uint32) tmp_val;
>        Py_DECREF (intobj);
>        return 1;
>    }
>    return 0;
> }