gnb@melba.bby.oz.au (Gregory Bond) (08/16/89)
Bash version 1.02, ChangeLog last edit Wed Jun 28 16:51:42 1989 Sun 3/60 using SunOS 3.5Export, gcc 1.35 and Sun cc. Typing ^D to bash to exit causes a core dump. Cause: The readline() routine returns a char * (the read line), or EOF on end of file. Somewhere between 1.01 and 1.02 the code in yy_readline_get() that handled the EOF was deleted, causing bash to xrealloc() with EOF as a pointer. Coredump. Fix: *** parse.y.orig Wed Aug 16 14:21:34 1989 --- parse.y Wed Aug 16 13:59:07 1989 *************** *** 427,436 **** --- 427,448 ---- if (!current_readline_prompt) current_readline_line = readline (""); else current_readline_line = readline (current_readline_prompt); + /* + * If you type a ^D to bash, then readline returns (char *)EOF + * This code avoids a coredump in xrealloc. It was in bash-1.01 + * in a similar form, but was dropped for 1.02. + * gnb@melba.bby.oz.au 16/8/89 + */ + if (current_readline_line == (char *)EOF) { + current_readline_line_index = 0; + current_readline_line == NULL; + return EOF; + } + current_readline_line_index = 0; current_readline_line = (char *)xrealloc (current_readline_line, 2 + strlen (current_readline_line)); strcat (current_readline_line, "\n");