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 /mpf | |
parent | 70fbe1ab8e61572540e627c588bf869c99b7696b (diff) | |
download | gmp-d7afa9ea9c7dae166cb6719c3b11db9c96cca519.tar.gz |
Make all bases either work or return an error.
Diffstat (limited to 'mpf')
-rw-r--r-- | mpf/get_str.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mpf/get_str.c b/mpf/get_str.c index 447bfdbb9..9b466f5e1 100644 --- a/mpf/get_str.c +++ b/mpf/get_str.c @@ -131,7 +131,7 @@ mpf_get_str (char *dbuf, mp_exp_t *exp, int base, size_t n_digits, mpf_srcptr u) if (base >= 0) { num_to_text = "0123456789abcdefghijklmnopqrstuvwxyz"; - if (base == 0) + if (base <= 1) base = 10; else if (base > 36) { @@ -143,6 +143,10 @@ mpf_get_str (char *dbuf, mp_exp_t *exp, int base, size_t n_digits, mpf_srcptr u) else { base = -base; + if (base <= 1) + base = 10; + else if (base > 36) + return NULL; num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } |