Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 273874) +++ main/asterisk.c (working copy) @@ -1597,14 +1597,18 @@ ast_module_shutdown(); } if (ast_opt_console || (ast_opt_remote && !ast_opt_exec)) { - if (getenv("HOME")) + if (getenv("HOME")) { snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME")); - if (!ast_strlen_zero(filename)) + } + if (!ast_strlen_zero(filename)) { ast_el_write_history(filename); - if (el != NULL) - el_end(el); - if (el_hist != NULL) + } + if (el != NULL) { + el = el_end(el); + } + if (el_hist != NULL) { history_end(el_hist); + } } if (option_verbose) ast_verbose("Executing last minute cleanups\n"); @@ -2512,19 +2516,22 @@ HistEvent ev; char *editor = getenv("AST_EDITOR"); - if (el != NULL) - el_end(el); - if (el_hist != NULL) + if (el != NULL) { + el = el_end(el); + } + if (el_hist != NULL) { history_end(el_hist); + } el = el_init("asterisk", stdin, stdout, stderr); el_set(el, EL_PROMPT, cli_prompt); - el_set(el, EL_EDITMODE, 1); - el_set(el, EL_EDITOR, editor ? editor : "emacs"); + el_set(el, EL_EDITMODE, 1); + el_set(el, EL_EDITOR, editor ? editor : "emacs"); el_hist = history_init(); - if (!el || !el_hist) + if (!el || !el_hist) { return -1; + } /* setup history with 100 entries */ history(el_hist, &ev, H_SETSIZE, 100); Index: main/editline/el.c =================================================================== --- main/editline/el.c (revision 273874) +++ main/editline/el.c (working copy) @@ -102,12 +102,12 @@ /* el_end(): * Clean up. */ -public void +public void * el_end(EditLine *el) { if (el == NULL) - return; + return NULL; el_reset(el); @@ -124,6 +124,7 @@ if (el->el_prog) el_free((ptr_t) el->el_prog); el_free((ptr_t) el); + return NULL; } Index: main/editline/read.c =================================================================== --- main/editline/read.c (revision 273874) +++ main/editline/read.c (working copy) @@ -363,9 +363,13 @@ int num; /* how many chars we have read at NL */ char ch; #ifdef FIONREAD - c_macro_t *ma = &el->el_chared.c_macro; + c_macro_t *ma; #endif /* FIONREAD */ + if (!el) { + return ""; + } + if (el->el_flags & HANDLE_SIGNALS) sig_set(el); @@ -396,6 +400,7 @@ ch_reset(el); #ifdef FIONREAD + ma = &el->el_chared.c_macro; if (el->el_tty.t_mode == EX_IO && ma->level < 0) { long chrs = 0; Index: main/editline/histedit.h =================================================================== --- main/editline/histedit.h (revision 273874) +++ main/editline/histedit.h (working copy) @@ -85,7 +85,7 @@ */ EditLine *el_init(const char *, FILE *, FILE *, FILE *); void el_reset(EditLine *); -void el_end(EditLine *); +void *el_end(EditLine *); /*