diff options
Diffstat (limited to 'mpz/gcd_ui.c')
-rw-r--r-- | mpz/gcd_ui.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mpz/gcd_ui.c b/mpz/gcd_ui.c index ee5bff81c..1e7976ba2 100644 --- a/mpz/gcd_ui.c +++ b/mpz/gcd_ui.c @@ -40,8 +40,16 @@ mpz_gcd_ui (mpz_ptr w, mpz_srcptr u, unsigned long int v) #if BITS_PER_ULONG > GMP_NUMB_BITS /* avoid warnings about shift amount */ if (v > GMP_NUMB_MAX) { - mpz_t vz; - mp_limb_t vlimbs[2]; + mpz_t vz, lw; + mp_limb_t vlimbs[2], wlimbs[2]; + + if (w == NULL) + { + PTR(lw) = wlimbs; + ALLOC(lw) = 2; + SIZ(lw) = 0; + w = lw; + } vlimbs[0] = v & GMP_NUMB_MASK; vlimbs[1] = v >> GMP_NUMB_BITS; PTR(vz) = vlimbs; |