summaryrefslogtreecommitdiff
path: root/data/bash/bash32-038
blob: 842b1b50196a170362089a7d4d474985a4e33d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
			     BASH PATCH REPORT
			     =================

Bash-Release: 3.2
Patch-ID: bash32-038

Bug-Reported-by:	Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>
Bug-Reference-ID:	<200803131141.m2DBf9vo001136@wojtek.tensor.gdynia.pl>
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2008-03/msg00029.html

Bug-Description:

When reading input lines into a single variable using the `read' builtin,
bash did not free the memory it read after assigining it to the named
variable, causing a memory leak noticable when reading large amounts of
data.


Patch:

*** ../bash-3.2-patched/builtins/read.def	2007-08-25 13:47:07.000000000 -0400
--- builtins/read.def	2008-03-07 12:55:47.000000000 -0500
***************
*** 135,139 ****
    char c;
    char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
!   char *e, *t, *t1, *ps2;
    struct stat tsb;
    SHELL_VAR *var;
--- 152,156 ----
    char c;
    char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
!   char *e, *t, *t1, *ps2, *tofree;
    struct stat tsb;
    SHELL_VAR *var;
***************
*** 675,678 ****
--- 728,732 ----
    /* Check whether or not the number of fields is exactly the same as the
       number of variables. */
+   tofree = NULL;
    if (*input_string)
      {
***************
*** 680,684 ****
        t = get_word_from_string (&input_string, ifs_chars, &e);
        if (*input_string == 0)
! 	input_string = t;
        else
  	input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
--- 734,738 ----
        t = get_word_from_string (&input_string, ifs_chars, &e);
        if (*input_string == 0)
! 	tofree = input_string = t;
        else
  	input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
***************
*** 695,698 ****
--- 749,754 ----
      var = bind_read_variable (list->word->word, input_string);
    stupidly_hack_special_variables (list->word->word);
+   FREE (tofree);
+ 
    if (var)
      VUNSETATTR (var, att_invisible);
*** ../bash-3.2/patchlevel.h	Thu Apr 13 08:31:04 2006
--- patchlevel.h	Mon Oct 16 14:22:54 2006
***************
*** 26,30 ****
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 37
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 38
  
  #endif /* _PATCHLEVEL_H_ */