From: Guido van Rossum Date: Mon, 11 Oct 1999 22:34:41 +0000 (+0000) Subject: Fix PR#66. Solution: add error checking around l_divmod() calls in X-Git-Tag: v1.6a1~826 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c7b8fe618600ed8ee73e48a70b1da05fa8fde49;p=thirdparty%2FPython%2Fcpython.git Fix PR#66. Solution: add error checking around l_divmod() calls in long_pow(). --- diff --git a/Objects/longobject.c b/Objects/longobject.c index 9f605a1470ea..0aecf8f8afa3 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1350,7 +1350,11 @@ long_pow(a, b, c) temp = (PyLongObject *)long_mul(z, a); Py_DECREF(z); if ((PyObject*)c!=Py_None && temp!=NULL) { - l_divmod(temp, c, &div, &mod); + if (l_divmod(temp,c,&div,&mod) < 0) { + Py_DECREF(temp); + z = NULL; + goto error; + } Py_XDECREF(div); Py_DECREF(temp); temp = mod; @@ -1365,7 +1369,11 @@ long_pow(a, b, c) temp = (PyLongObject *)long_mul(a, a); Py_DECREF(a); if ((PyObject*)c!=Py_None && temp!=NULL) { - l_divmod(temp, c, &div, &mod); + if (l_divmod(temp, c, &div, &mod) < 0) { + Py_DECREF(temp); + z = NULL; + goto error; + } Py_XDECREF(div); Py_DECREF(temp); temp = mod; @@ -1382,11 +1390,17 @@ long_pow(a, b, c) } Py_XDECREF(a); if ((PyObject*)c!=Py_None && z!=NULL) { - l_divmod(z, c, &div, &mod); + if (l_divmod(z, c, &div, &mod) < 0) { + Py_DECREF(z); + z = NULL; + } + else { Py_XDECREF(div); Py_DECREF(z); - z=mod; + z = mod; + } } + error: return (PyObject *)z; }