Roman Rakus 2cb460
			     BASH PATCH REPORT
Roman Rakus 2cb460
			     =================
Roman Rakus 2cb460
Roman Rakus 2cb460
Bash-Release: 3.2
Roman Rakus 2cb460
Patch-ID: bash32-038
Roman Rakus 2cb460
Roman Rakus 2cb460
Bug-Reported-by:	Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>
Roman Rakus 2cb460
Bug-Reference-ID:	<200803131141.m2DBf9vo001136@wojtek.tensor.gdynia.pl>
Roman Rakus 2cb460
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2008-03/msg00029.html
Roman Rakus 2cb460
Roman Rakus 2cb460
Bug-Description:
Roman Rakus 2cb460
Roman Rakus 2cb460
When reading input lines into a single variable using the `read' builtin,
Roman Rakus 2cb460
bash did not free the memory it read after assigining it to the named
Roman Rakus 2cb460
variable, causing a memory leak noticable when reading large amounts of
Roman Rakus 2cb460
data.
Roman Rakus 2cb460
Roman Rakus 2cb460
Roman Rakus 2cb460
Patch:
Roman Rakus 2cb460
Roman Rakus 2cb460
*** ../bash-3.2-patched/builtins/read.def	2007-08-25 13:47:07.000000000 -0400
Roman Rakus 2cb460
--- builtins/read.def	2008-03-07 12:55:47.000000000 -0500
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 135,139 ****
Roman Rakus 2cb460
    char c;
Roman Rakus 2cb460
    char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
Roman Rakus 2cb460
!   char *e, *t, *t1, *ps2;
Roman Rakus 2cb460
    struct stat tsb;
Roman Rakus 2cb460
    SHELL_VAR *var;
Roman Rakus 2cb460
--- 152,156 ----
Roman Rakus 2cb460
    char c;
Roman Rakus 2cb460
    char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
Roman Rakus 2cb460
!   char *e, *t, *t1, *ps2, *tofree;
Roman Rakus 2cb460
    struct stat tsb;
Roman Rakus 2cb460
    SHELL_VAR *var;
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 675,678 ****
Roman Rakus 2cb460
--- 728,732 ----
Roman Rakus 2cb460
    /* Check whether or not the number of fields is exactly the same as the
Roman Rakus 2cb460
       number of variables. */
Roman Rakus 2cb460
+   tofree = NULL;
Roman Rakus 2cb460
    if (*input_string)
Roman Rakus 2cb460
      {
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 680,684 ****
Roman Rakus 2cb460
        t = get_word_from_string (&input_string, ifs_chars, &e);
Roman Rakus 2cb460
        if (*input_string == 0)
Roman Rakus 2cb460
! 	input_string = t;
Roman Rakus 2cb460
        else
Roman Rakus 2cb460
  	input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
Roman Rakus 2cb460
--- 734,738 ----
Roman Rakus 2cb460
        t = get_word_from_string (&input_string, ifs_chars, &e);
Roman Rakus 2cb460
        if (*input_string == 0)
Roman Rakus 2cb460
! 	tofree = input_string = t;
Roman Rakus 2cb460
        else
Roman Rakus 2cb460
  	input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 695,698 ****
Roman Rakus 2cb460
--- 749,754 ----
Roman Rakus 2cb460
      var = bind_read_variable (list->word->word, input_string);
Roman Rakus 2cb460
    stupidly_hack_special_variables (list->word->word);
Roman Rakus 2cb460
+   FREE (tofree);
Roman Rakus 2cb460
+ 
Roman Rakus 2cb460
    if (var)
Roman Rakus 2cb460
      VUNSETATTR (var, att_invisible);
Roman Rakus 2cb460
*** ../bash-3.2/patchlevel.h	Thu Apr 13 08:31:04 2006
Roman Rakus 2cb460
--- patchlevel.h	Mon Oct 16 14:22:54 2006
Roman Rakus 2cb460
***************
Roman Rakus 2cb460
*** 26,30 ****
Roman Rakus 2cb460
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 2cb460
  
Roman Rakus 2cb460
! #define PATCHLEVEL 37
Roman Rakus 2cb460
  
Roman Rakus 2cb460
  #endif /* _PATCHLEVEL_H_ */
Roman Rakus 2cb460
--- 26,30 ----
Roman Rakus 2cb460
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 2cb460
  
Roman Rakus 2cb460
! #define PATCHLEVEL 38
Roman Rakus 2cb460
  
Roman Rakus 2cb460
  #endif /* _PATCHLEVEL_H_ */