[gnu.bash.bug] bug in bash

jbayer@ispi.com (Jonathan Bayer) (08/29/89)

While installing bash on SCO Xenix 386 2.3.2 using the 2.3 development
system, I kept getting core dumps when typing a control-d at the
prompt.  I traced this to readline and parse.y.  It seems that when
an eof is read that readline returns a (char *)EOF.  Now, EOF is defined
as a -1 on this system.  Right after the readline is a call to xrealloc.
xrealloc was bombing on the call to realloc because it was passed a bad
pointer.  My solution (not necessarily the best) was to put a check in
parse.y, checking for a (char *)EOF.  If found, it mallocs a 2 char
string, puts the EOF in the first byte, and a 0 in the second byte. 
This seems to solve the problem.


JB


*** parse.y.std	Mon Aug 28 12:43:47 1989
--- parse.y	Mon Aug 28 17:09:59 1989
***************
*** 430,439 ****
  	current_readline_line = readline (current_readline_prompt);
  
        current_readline_line_index = 0;
!       current_readline_line =
! 	(char *)xrealloc (current_readline_line,
! 			  2 + strlen (current_readline_line));
!       strcat (current_readline_line, "\n");
      }
  
    if (!current_readline_line[current_readline_line_index])
--- 430,447 ----
  	current_readline_line = readline (current_readline_prompt);
  
        current_readline_line_index = 0;
! 
!       if (current_readline_line == (char *)EOF) {
! 		current_readline_line = (char *)xmalloc(2);
! 		strcpy(" ",current_readline_line);
! 		current_readline_line[0] = EOF;
!       } else {
! 		
!          current_readline_line =
! 	   (char *)xrealloc (current_readline_line,
! 			     2 + strlen (current_readline_line));
!          strcat (current_readline_line, "\n");
!        }
      }
  
    if (!current_readline_line[current_readline_line_index])



-- 
Jonathan Bayer		Intelligent Software Products, Inc.
(201) 245-5922		500 Oakwood Ave.
jbayer@ispi.COM		Roselle Park, NJ   07204