From 0533a7303bde22d10c3726622086115f0abfe1d4 Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Sun, 21 May 2000 01:08:05 +0200 Subject: * 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. --- mpz/iset_str.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mpz') 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); } -- cgit v1.2.1