diff options
author | Kevin Ryde <user42@zip.com.au> | 2002-06-29 02:49:01 +0200 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2002-06-29 02:49:01 +0200 |
commit | 916245309b66ce5577d239760321f2e71b997460 (patch) | |
tree | f5f2c8b47386e9f5a69363da70177889a588d870 /mpf/inp_str.c | |
parent | 3837b87baccc1fead3dfed4e693ba79663b91a57 (diff) | |
download | gmp-916245309b66ce5577d239760321f2e71b997460.tar.gz |
* mpf/inp_str.c: Fix returned count of chars read, reported by Paul
Zimmermann. Also fix a memory leak for invalid input.
Diffstat (limited to 'mpf/inp_str.c')
-rw-r--r-- | mpf/inp_str.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mpf/inp_str.c b/mpf/inp_str.c index 1af7a95b2..140ec2a1a 100644 --- a/mpf/inp_str.c +++ b/mpf/inp_str.c @@ -1,7 +1,7 @@ /* mpf_inp_str(dest_float, stream, base) -- Input a number in base BASE from stdio stream STREAM and store the result in DEST_FLOAT. -Copyright 1996, 2000, 2001 Free Software Foundation, Inc. +Copyright 1996, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -64,6 +64,7 @@ mpf_inp_str (mpf_ptr rop, FILE *stream, int base) c = getc (stream); } ungetc (c, stream); + nread--; if (str_size >= alloc_size) { @@ -74,9 +75,10 @@ mpf_inp_str (mpf_ptr rop, FILE *stream, int base) str[str_size] = 0; retval = mpf_set_str (rop, str, base); + (*__gmp_free_func) (str, alloc_size); + if (retval == -1) return 0; /* error */ - (*__gmp_free_func) (str, alloc_size); return str_size + nread; } |