mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Fix PR#66. Solution: add error checking around l_divmod() calls in
long_pow().
This commit is contained in:
parent
1b7aec35c4
commit
2c7b8fe618
1 changed files with 18 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue