mini-gmp: mpz_init_set_str fails on leading zeroes

Niels Möller nisse at
Sun Aug 14 14:40:41 UTC 2016

Austyn Krutsinger <akrutsinger at> writes:

> I think the attached patch provides a reasonable solution. The only
> function effected is mpn_set_str_other() and since this particular function
> is unique to mini-gmp, 

I'm looking into this now. I'm leaning towards lettong mpn_set_str_other
return 1 for all-zero input, and let the caller, mpz_set_str, deal with
normalization (mpn_set_str doesn't need to, since it doesn't promise
normalization if the input has leading zeros).

I also found another corner case where the current implementation is
broken: Calling mpz_set_str with an empty string as input. Have to
check if the real gmp treats that as invalid or as zero.


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-bugs mailing list