Patch by Tim Peters fixing PR#88:

Integer division can crash under Windows.
This commit is contained in:
Guido van Rossum 1999-09-27 17:12:47 +00:00
parent 1a23c2484e
commit e13ff2e2d6
1 changed files with 7 additions and 1 deletions

View File

@ -434,8 +434,14 @@ i_divmod(x, y, p_xdivy, p_xmody)
return -1;
}
if (yi < 0) {
if (xi < 0)
if (xi < 0) {
if (yi == -1 && -xi < 0) {
/* most negative / -1 */
err_ovf("integer division");
return -1;
}
xdivy = -xi / -yi;
}
else
xdivy = - (xi / -yi);
}