07a490
			     BASH PATCH REPORT
07a490
			     =================
07a490
07a490
Bash-Release:	4.2
07a490
Patch-ID:	bash42-009
07a490
07a490
Bug-Reported-by:	<piuma@piumalab.org>
07a490
Bug-Reference-ID:	<4DAAC0DB.7060606@piumalab.org>
07a490
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2011-04/msg00075.html
07a490
07a490
Bug-Description:
07a490
07a490
Under certain circumstances, running `fc -l' two times in succession with a
07a490
relative history offset at the end of the history will result in an incorrect
07a490
calculation of the last history entry and a seg fault.
07a490
07a490
Patch (apply with `patch -p0'):
07a490
07a490
*** ../bash-4.2-patched/builtins/fc.def	2010-05-30 18:25:38.000000000 -0400
07a490
--- builtins/fc.def	2011-04-19 15:46:17.000000000 -0400
07a490
***************
07a490
*** 305,309 ****
07a490
  
07a490
    /* XXX */
07a490
!   if (saved_command_line_count > 0 && i == last_hist && hlist[last_hist] == 0)
07a490
      while (last_hist >= 0 && hlist[last_hist] == 0)
07a490
        last_hist--;
07a490
--- 305,309 ----
07a490
  
07a490
    /* XXX */
07a490
!   if (i == last_hist && hlist[last_hist] == 0)
07a490
      while (last_hist >= 0 && hlist[last_hist] == 0)
07a490
        last_hist--;
07a490
***************
07a490
*** 476,480 ****
07a490
  {
07a490
    int sign, n, clen, rh;
07a490
!   register int i, j;
07a490
    register char *s;
07a490
  
07a490
--- 476,480 ----
07a490
  {
07a490
    int sign, n, clen, rh;
07a490
!   register int i, j, last_hist;
07a490
    register char *s;
07a490
  
07a490
***************
07a490
*** 496,500 ****
07a490
       calculation as if it were on. */
07a490
    rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
07a490
!   i -= rh + hist_last_line_added;
07a490
  
07a490
    /* No specification defaults to most recent command. */
07a490
--- 496,508 ----
07a490
       calculation as if it were on. */
07a490
    rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
07a490
!   last_hist = i - rh - hist_last_line_added;
07a490
! 
07a490
!   if (i == last_hist && hlist[last_hist] == 0)
07a490
!     while (last_hist >= 0 && hlist[last_hist] == 0)
07a490
!       last_hist--;
07a490
!   if (last_hist < 0)
07a490
!     return (-1);
07a490
! 
07a490
!   i = last_hist;
07a490
  
07a490
    /* No specification defaults to most recent command. */
07a490
*** ../bash-4.2-patched/patchlevel.h	Sat Jun 12 20:14:48 2010
07a490
--- patchlevel.h	Thu Feb 24 21:41:34 2011
07a490
***************
07a490
*** 26,30 ****
07a490
     looks for to find the patch level (for the sccs version string). */
07a490
  
07a490
! #define PATCHLEVEL 8
07a490
  
07a490
  #endif /* _PATCHLEVEL_H_ */
07a490
--- 26,30 ----
07a490
     looks for to find the patch level (for the sccs version string). */
07a490
  
07a490
! #define PATCHLEVEL 9
07a490
  
07a490
  #endif /* _PATCHLEVEL_H_ */