[Ecm-commits] r2433 - branches/6.4.4

cvs commits ecm-commits at lists.gforge.inria.fr
Fri Feb 22 13:26:10 CET 2013


Author: kruppa
Date: 2013-02-22 13:26:09 +0100 (Fri, 22 Feb 2013)
New Revision: 2433

Log:
Use malloc() instead of alloca() for tmp in mpn_fft_fft_bailey_decompose() 
to avoid segfault with very large stage 2


Modified:
   branches/6.4.4/mul_fft.c
Modified: branches/6.4.4/mul_fft.c
===================================================================
--- branches/6.4.4/mul_fft.c	2013-02-21 17:29:37 UTC (rev 2432)
+++ branches/6.4.4/mul_fft.c	2013-02-22 12:26:09 UTC (rev 2433)
@@ -1607,7 +1607,7 @@
   const mp_size_t K2 = 1 << k2;
   mp_size_t omegai;
   mp_ptr *BufA; 
-  mp_ptr T, tmp;
+  mp_ptr T, tmp = NULL;
   const int Kl = l << k;
     
   TMP_DECL;
@@ -1621,7 +1621,7 @@
 
   if (nl > Kl)
     {
-      tmp = TMP_ALLOC_LIMBS(Kl + 1);
+      tmp = __GMP_ALLOCATE_FUNC_LIMBS(Kl + 1);
       ASSERT(tmp != NULL);
       mpn_mul_fft_reduce (tmp, /* A, */ n, nl, Kl, /* l, */ b);
       n = tmp;
@@ -1645,6 +1645,12 @@
       Ap[i+K2*j] = BufA[j];
   }
 
+  if (tmp != NULL) {
+    __GMP_FREE_FUNC_LIMBS(tmp, Kl + 1);
+    tmp = NULL;
+    n = NULL; /* n is now likewise invalid */
+  }
+
   omegai = omega<<k1;
   for (j = 0; j < K1; ++j)
     mpn_fft_fft_radix4(Ap+j*K2, k2, omegai, nprime, rotbuf);




More information about the Ecm-commits mailing list