summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--missing/dtoa.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/missing/dtoa.c b/missing/dtoa.c
index 8859fcfa44..4d266ecf12 100644
--- a/missing/dtoa.c
+++ b/missing/dtoa.c
@@ -699,6 +699,8 @@ i2b(int i)
return b;
}
+#define Bzero_p(b) (!(b)->x[0] && (b)->wds <= 1)
+
static Bigint *
mult(Bigint *a, Bigint *b)
{
@@ -715,6 +717,13 @@ mult(Bigint *a, Bigint *b)
#endif
#endif
+ if (Bzero_p(a) || Bzero_p(b)) {
+ c = Balloc(0);
+ c->wds = 1;
+ c->x[0] = 0;
+ return c;
+ }
+
if (a->wds < b->wds) {
c = a;
a = b;
@@ -862,6 +871,8 @@ lshift(Bigint *b, int k)
Bigint *b1;
ULong *x, *x1, *xe, z;
+ if (!k || Bzero_p(b)) return b;
+
#ifdef Pack_32
n = k >> 5;
#else