diff options
author | Torbjorn Granlund <tege@gmplib.org> | 2010-11-22 22:03:28 +0100 |
---|---|---|
committer | Torbjorn Granlund <tege@gmplib.org> | 2010-11-22 22:03:28 +0100 |
commit | d7afa9ea9c7dae166cb6719c3b11db9c96cca519 (patch) | |
tree | 4a5faa1be01e8ec09b1379d464eac7527b011f2c /mpz/get_str.c | |
parent | 70fbe1ab8e61572540e627c588bf869c99b7696b (diff) | |
download | gmp-d7afa9ea9c7dae166cb6719c3b11db9c96cca519.tar.gz |
Make all bases either work or return an error.
Diffstat (limited to 'mpz/get_str.c')
-rw-r--r-- | mpz/get_str.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mpz/get_str.c b/mpz/get_str.c index 613d210a7..c5766f133 100644 --- a/mpz/get_str.c +++ b/mpz/get_str.c @@ -43,7 +43,7 @@ mpz_get_str (char *res_str, int base, mpz_srcptr x) if (base >= 0) { num_to_text = "0123456789abcdefghijklmnopqrstuvwxyz"; - if (base == 0) + if (base <= 1) base = 10; else if (base > 36) { @@ -55,6 +55,10 @@ mpz_get_str (char *res_str, int base, mpz_srcptr x) else { base = -base; + if (base <= 1) + base = 10; + else if (base > 36) + return NULL; num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } |