#! /bin/sh -e if [ $# -eq 3 -a "$2" = '-d' ]; then pdir="-d $3" elif [ $# -ne 1 ]; then echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" exit 1 fi case "$1" in -patch) patch $pdir -f --no-backup-if-mismatch -p0 < $0;; -unpatch) patch $pdir -f --no-backup-if-mismatch -R -p0 < $0;; *) echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" exit 1 esac exit 0 # DP: bash-3.2 upstream patch bash32-038 BASH PATCH REPORT ================= Bash-Release: 3.2 Patch-ID: bash32-038 Bug-Reported-by: Wojciech Puchar 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_ */