diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2022-02-14 14:57:38 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2022-02-14 14:57:38 +0100 |
commit | 8deb5a014f6cf65ef1b6f749359912e7561e35c4 (patch) | |
tree | 339f8a86aa28cb0a70ffbb4cca99910ec9274cf4 /mpz | |
parent | eceabe21eb6d50eecab04fed613f5d8ffb415e5c (diff) | |
download | gmp-8deb5a014f6cf65ef1b6f749359912e7561e35c4.tar.gz |
mpz/gcd_ui.c: Handle NULL in (v > GMP_NUMB_MAX) branch (unused)
Diffstat (limited to 'mpz')
-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; |