summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortege <tege@gmplib.org>2000-04-16 20:02:07 +0200
committertege <tege@gmplib.org>2000-04-16 20:02:07 +0200
commit79b137ee79e3e9abc46b0a0abe961b951d705ae9 (patch)
tree4f5e60c155c8153dad5e3897ee260216d6b52319
parent008d9292e23b3453219e2b0a2f38b7d20f680f1c (diff)
downloadgmp-79b137ee79e3e9abc46b0a0abe961b951d705ae9.tar.gz
Fix memory leakage.
-rw-r--r--mpz/inp_str.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/mpz/inp_str.c b/mpz/inp_str.c
index 0120cde40..6545797c3 100644
--- a/mpz/inp_str.c
+++ b/mpz/inp_str.c
@@ -66,9 +66,6 @@ mpz_inp_str (x, stream, base)
if (stream == 0)
stream = stdin;
- alloc_size = 100;
- str = (char *) (*_mp_allocate_func) (alloc_size);
- str_size = 0;
nread = 0;
/* Skip whitespace. */
@@ -122,6 +119,10 @@ mpz_inp_str (x, stream, base)
nread++;
}
+ alloc_size = 100;
+ str = (char *) (*_mp_allocate_func) (alloc_size);
+ str_size = 0;
+
for (;;)
{
int dig;
@@ -144,6 +145,7 @@ mpz_inp_str (x, stream, base)
if (str_size == 0)
{
x->_mp_size = 0;
+ (*_mp_free_func) (str, alloc_size);
return nread;
}