summaryrefslogtreecommitdiff
path: root/mpf
diff options
context:
space:
mode:
authorTorbjorn Granlund <tege@gmplib.org>2010-11-22 22:03:28 +0100
committerTorbjorn Granlund <tege@gmplib.org>2010-11-22 22:03:28 +0100
commitd7afa9ea9c7dae166cb6719c3b11db9c96cca519 (patch)
tree4a5faa1be01e8ec09b1379d464eac7527b011f2c /mpf
parent70fbe1ab8e61572540e627c588bf869c99b7696b (diff)
downloadgmp-d7afa9ea9c7dae166cb6719c3b11db9c96cca519.tar.gz
Make all bases either work or return an error.
Diffstat (limited to 'mpf')
-rw-r--r--mpf/get_str.c6
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";
}