From 8deb5a014f6cf65ef1b6f749359912e7561e35c4 Mon Sep 17 00:00:00 2001 From: Marco Bodrato Date: Mon, 14 Feb 2022 14:57:38 +0100 Subject: mpz/gcd_ui.c: Handle NULL in (v > GMP_NUMB_MAX) branch (unused) --- mpz/gcd_ui.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'mpz') 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; -- cgit v1.2.1