fixed (modulo <bignum> 0) and (modulo <bignum> <largish-fixnum>)

errors that caused either a segfault or returning an incorrect
value.
This commit is contained in:
Abdulaziz Ghuloum 2009-06-26 11:15:02 +03:00
parent f495665f7d
commit 1803f9f23c
3 changed files with 5 additions and 3 deletions

View File

@ -1737,7 +1737,9 @@
[(bignum? n)
(cond
[(fixnum? m)
(foreign-call "ikrt_bnfx_modulo" n m)]
(if (eqv? m 0)
(die 'modulo "division by zero" n m)
(foreign-call "ikrt_bnfx_modulo" n m))]
[(bignum? m)
(if ($bignum-positive? n)
(if ($bignum-positive? m)

View File

@ -1 +1 @@
1809
1810

View File

@ -1797,7 +1797,7 @@ ikrt_bnfxdivrem(ikptr x, ikptr y, ikpcb* pcb){
ikptr
ikrt_bnfx_modulo(ikptr x, ikptr y /*, ikpcb* pcb */){
int yint = unfix(y);
long int yint = unfix(y);
mp_limb_t* s2p = (mp_limb_t*)(long)(x+off_bignum_data);
ikptr fst = ref(x, -vector_tag);
mp_size_t s2n = bnfst_limb_count(fst);