1 # DP: bash-4.2 upstream patch 009
9 Bug-Reported-by: <piuma@piumalab.org>
10 Bug-Reference-ID: <4DAAC0DB.7060606@piumalab.org>
11 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2011-04/msg00075.html
15 Under certain circumstances, running `fc -l' two times in succession with a
16 relative history offset at the end of the history will result in an incorrect
17 calculation of the last history entry and a seg fault.
19 Patch (apply with `patch -p0'):
21 --- a/bash/builtins/fc.def
22 +++ b/bash/builtins/fc.def
24 last_hist = i - rh - hist_last_line_added;
27 - if (saved_command_line_count > 0 && i == last_hist && hlist[last_hist] == 0)
28 + if (i == last_hist && hlist[last_hist] == 0)
29 while (last_hist >= 0 && hlist[last_hist] == 0)
35 int sign, n, clen, rh;
37 + register int i, j, last_hist;
42 has been enabled (interactive or not) should use it in the last_hist
43 calculation as if it were on. */
44 rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
45 - i -= rh + hist_last_line_added;
46 + last_hist = i - rh - hist_last_line_added;
48 + if (i == last_hist && hlist[last_hist] == 0)
49 + while (last_hist >= 0 && hlist[last_hist] == 0)
56 /* No specification defaults to most recent command. */
58 --- a/bash/patchlevel.h
59 +++ b/bash/patchlevel.h
61 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
62 looks for to find the patch level (for the sccs version string). */
67 #endif /* _PATCHLEVEL_H_ */