Article View: gnu.bash.bug
Article #512bug in bash (and fix)
From: Jonathan Bayer
Date: Mon, 28 Aug 1989 21:31
Date: Mon, 28 Aug 1989 21:31
55 lines
2302 bytes
2302 bytes
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
Technical Details
Message-ID:
<8908281731.AA05365@ispi.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!ginosko!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ispi.com!jbayerShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!ginosko!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ispi.com!jbayer From: jbayer@ispi.com (Jonathan Bayer) Newsgroups: gnu.bash.bug Subject: bug in bash (and fix) Message-ID: <8908281731.AA05365@ispi.COM> Date: 28 Aug 89 21:31:54 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 55