]> granicus.if.org Git - python/commitdiff
Issue #7743: Add checks for zero inputs to the lshift and mult functions;
authorMark Dickinson <dickinsm@gmail.com>
Sat, 23 Jan 2010 20:48:56 +0000 (20:48 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sat, 23 Jan 2010 20:48:56 +0000 (20:48 +0000)
this fixes the first bug described in issue #7743.

Python/dtoa.c

index 6e11b9a757fb63e9d51a7739995e840869b7a3b9..6a93aef3bda13aaf3d5eb9b0d2c00dcd99c351ff 100644 (file)
@@ -622,6 +622,15 @@ mult(Bigint *a, Bigint *b)
     ULong z2;
 #endif
 
+    if ((!a->x[0] && a->wds == 1) || (!b->x[0] && b->wds == 1)) {
+        c = Balloc(0);
+        if (c == NULL)
+            return NULL;
+        c->wds = 1;
+        c->x[0] = 0;
+        return c;
+    }
+
     if (a->wds < b->wds) {
         c = a;
         a = b;
@@ -820,6 +829,9 @@ lshift(Bigint *b, int k)
     Bigint *b1;
     ULong *x, *x1, *xe, z;
 
+    if (!k || (!b->x[0] && b->wds == 1))
+        return b;
+
     n = k >> 5;
     k1 = b->k;
     n1 = n + b->wds + 1;