segfault in mpz_divexact()
Antony Dovgal
antony at zend.com
Wed Apr 25 19:58:32 CEST 2007
On 04/25/2007 09:04 PM, Torbjorn Granlund wrote:
> Antony Dovgal <antony at zend.com> writes:
> I decided to make the code avoid the crash.
> Please try this fix:
The patch looks good, thanks a lot.
> *** mpz/divexact.c 27 Apr 2006 16:30:18 -0000 1.2
> --- mpz/divexact.c 25 Apr 2007 17:02:13 -0000 1.3
> *************** mpz_divexact (mpz_ptr quot, mpz_srcptr n
> *** 66,73 ****
> qp = quot->_mp_d;
>
> ! if (nsize == 0)
> {
> ! if (dsize == 0)
> ! DIVIDE_BY_ZERO;
> quot->_mp_size = 0;
> return;
> --- 66,74 ----
> qp = quot->_mp_d;
>
> ! if (nsize < dsize)
> {
> ! /* This special case avoids segfaults below when the function is
> ! incorrectly called with |N| < |D|, N != 0. It also handles the
> ! well-defined case N = 0. */
> quot->_mp_size = 0;
> return;
>
>
--
Wbr,
Antony Dovgal
More information about the gmp-bugs
mailing list