]> granicus.if.org Git - python/commitdiff
Patch by Tim Peters fixing PR#88:
authorGuido van Rossum <guido@python.org>
Mon, 27 Sep 1999 17:12:47 +0000 (17:12 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 27 Sep 1999 17:12:47 +0000 (17:12 +0000)
Integer division can crash under Windows.

Objects/intobject.c

index 7293515e6c30981b0ee22ded5a54e04e59117bcf..f2d77e1a730373bac935cc35085e688b5c95e421 100644 (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);
        }