diff options
| author | Charles.Forsyth <devnull@localhost> | 2008-06-12 21:45:38 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2008-06-12 21:45:38 +0000 |
| commit | d9bd3181330830c49e714609e86eaa3e39a884ca (patch) | |
| tree | 9836330fa12c11f4dafce942e3eb23f8fcdf80c9 /libmp/port/mpfactorial.c | |
| parent | 3d7a0c16959c77d931f7fdd2022945a563bbff10 (diff) | |
20080612-2245
Diffstat (limited to 'libmp/port/mpfactorial.c')
| -rw-r--r-- | libmp/port/mpfactorial.c | 8 |
1 files changed, 6 insertions, 2 deletions
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; |
