Index: mpn/generic/rootrem.c
===================================================================
RCS file: /home/cvsfiles/gmp/mpn/generic/rootrem.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -c -1 -r1.7 -r1.8
*** mpn/generic/rootrem.c	17 Dec 2002 00:19:07 -0000	1.7
--- mpn/generic/rootrem.c	19 Dec 2002 01:13:23 -0000	1.8
***************
*** 67,69 ****
    TMP_MARK (marker);
!   pp = TMP_ALLOC_LIMBS (un + 2);
  
--- 67,79 ----
    TMP_MARK (marker);
! 
!   /* The extra factor 1.585 = log(3)/log(2) here is for the worst case
!      overestimate of the root, i.e., when the code rounds a root that is
!      2+epsilon to 3, and the powers this to a potentially huge power.  We
!      could generalize the code for detecting root=1 a few lines below to deal
!      with xnb <= k, for some small k.  For example, when xnb <= 2, meaning
!      the root should be 1, 2, or 3, we could replace this factor by the much
!      smaller log(5)/log(4).  */
! 
! #define PP_ALLOC (2 + (mp_size_t) (un*1.585))
!   pp = TMP_ALLOC_LIMBS (PP_ALLOC);
  
***************
*** 104,105 ****
--- 114,116 ----
        pn = mpn_pow_1 (pp, xp, xn, nth, qp);
+       ASSERT_ALWAYS (pn < PP_ALLOC);
        /* If the new root approximation is too small, restore old value.  */
***************
*** 123,124 ****
--- 134,136 ----
        pn = mpn_pow_1 (pp, xp, xn, nth - 1, qp);
+       ASSERT_ALWAYS (pn < PP_ALLOC);
        mpn_tdiv_qr (qp, pp, (mp_size_t) 0, up, un, pp, pn); /* junk remainder */
***************
*** 147,148 ****
--- 159,161 ----
    pn = mpn_pow_1 (pp, xp, xn, nth, qp);
+   ASSERT_ALWAYS (pn < PP_ALLOC);
    if (un < pn || (un == pn && mpn_cmp (up, pp, pn) < 0))
***************
*** 151,152 ****
--- 164,166 ----
        pn = mpn_pow_1 (pp, xp, xn, nth, qp);
+       ASSERT_ALWAYS (pn < PP_ALLOC);
  
