bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory leak in read builtin


From: Andreas Schwab
Subject: Re: memory leak in read builtin
Date: Sat, 10 Nov 2007 02:17:11 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (gnu/linux)

Chet Ramey <chet.ramey@case.edu> writes:

> That code is quite different in bash-3.2, and the memory leak is gone.

Definitely neither.

---
 builtins/read.def |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Index: builtins/read.def
===================================================================
--- builtins/read.def.orig      2007-11-10 01:20:45.000000000 +0100
+++ builtins/read.def   2007-11-10 02:03:38.000000000 +0100
@@ -134,7 +134,7 @@ read_builtin (list)
   intmax_t intval;
   char c;
   char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
-  char *e, *t, *t1, *ps2;
+  char *e, *t, *t1, *t2, *ps2;
   struct stat tsb;
   SHELL_VAR *var;
 #if defined (ARRAY_VARS)
@@ -677,12 +677,14 @@ add_char:
   if (*input_string)
     {
       t1 = input_string;
-      t = get_word_from_string (&input_string, ifs_chars, &e);
+      t2 = get_word_from_string (&input_string, ifs_chars, &e);
       if (*input_string == 0)
-       input_string = t;
+       input_string = t2;
       else
        input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, 
saw_escape);
     }
+  else
+    t2 = NULL;
 #endif
 
   if (saw_escape)
@@ -696,6 +698,7 @@ add_char:
   stupidly_hack_special_variables (list->word->word);
   if (var)
     VUNSETATTR (var, att_invisible);
+  FREE (t2);
   xfree (orig_input_string);
 
   return (retval);

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]