diff options
author | Guido van Rossum <guido@python.org> | 1999-10-11 22:34:41 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-10-11 22:34:41 (GMT) |
commit | 2c7b8fe618600ed8ee73e48a70b1da05fa8fde49 (patch) | |
tree | 2c1975632195d081709ced21b550951020c8bc61 /Objects/longobject.c | |
parent | 1b7aec35c43360ed1ec699458cc103e3223aac14 (diff) | |
download | cpython-2c7b8fe618600ed8ee73e48a70b1da05fa8fde49.zip cpython-2c7b8fe618600ed8ee73e48a70b1da05fa8fde49.tar.gz cpython-2c7b8fe618600ed8ee73e48a70b1da05fa8fde49.tar.bz2 |
Fix PR#66. Solution: add error checking around l_divmod() calls in
long_pow().
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 9f605a1..0aecf8f 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; } |