diff options
author | Kevin Ryde <user42@zip.com.au> | 2000-05-21 01:08:05 +0200 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2000-05-21 01:08:05 +0200 |
commit | 0533a7303bde22d10c3726622086115f0abfe1d4 (patch) | |
tree | e0d2e3494d34515be2f7fc465976537a08d46ce0 /mpz | |
parent | df91cc03e7d08d162d8a0cd65a241e8817a0ef79 (diff) | |
download | gmp-0533a7303bde22d10c3726622086115f0abfe1d4.tar.gz |
* mpz/iset_str.c: Initialize _mp_size to 0, in case no digits in
string; this makes it the same as a separate init and set_str.
This showed up in the INSTALL demo program, where typing garbage
arguments like "./a.out xx yy" to the second version of the program
produced a segv. In any case it seems like a good idea for the
combined init/set functions to be identical to separate calls.
Diffstat (limited to 'mpz')
-rw-r--r-- | mpz/iset_str.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mpz/iset_str.c b/mpz/iset_str.c index e04ad5da2..03a536429 100644 --- a/mpz/iset_str.c +++ b/mpz/iset_str.c @@ -5,7 +5,7 @@ i.e. 0xhh...h means base 16, 0oo...o means base 8, otherwise assume base 10. -Copyright (C) 1991, 1993, 1994, 1995 Free Software Foundation, Inc. +Copyright (C) 1991, 1993, 1994, 1995, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -40,5 +40,8 @@ mpz_init_set_str (x, str, base) x->_mp_alloc = 1; x->_mp_d = (mp_ptr) (*_mp_allocate_func) (BYTES_PER_MP_LIMB); + /* if str has no digits mpz_set_str leaves x->_mp_size unset */ + x->_mp_size = 0; + return mpz_set_str (x, str, base); } |