From d9bd3181330830c49e714609e86eaa3e39a884ca Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Thu, 12 Jun 2008 21:45:38 +0000 Subject: 20080612-2245 --- libmp/port/mpfactorial.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libmp/port/mpfactorial.c') diff --git a/libmp/port/mpfactorial.c b/libmp/port/mpfactorial.c index 01079c44..b0e22ce2 100644 --- a/libmp/port/mpfactorial.c +++ b/libmp/port/mpfactorial.c @@ -42,8 +42,12 @@ mpfactorial(ulong n) max++; if(max > mmax){ mmax++; - if(max > nelem(stk)) - abort(); + if(max >= nelem(stk)){ + while(--max >= 0) + mpfree(stk[max]); + mpfree(r); + sysfatal("mpfactorial: stack overflow"); + } stk[max] = mpnew(Dbits); } stk[max]->top = 1; -- cgit v1.2.3