Fix PR#66. Solution: add error checking around l_divmod() calls in

long_pow().
This commit is contained in:
Guido van Rossum 1999-10-11 22:34:41 +00:00
parent 1b7aec35c4
commit 2c7b8fe618

View file

@ -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;
}