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