diff options
author | Chris Johns <chrisj@rtems.org> | 2023-01-30 13:59:11 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2023-01-30 13:59:11 +1100 |
commit | 45f60cfbcff6ab714c441d6c87b6ff919f02f49f (patch) | |
tree | eacb558d20a82991344625a61fe9d16caea6ef10 | |
parent | libmisc/shell/chmod: Fix multiple file arguments to the command (diff) | |
download | rtems-45f60cfbcff6ab714c441d6c87b6ff919f02f49f.tar.bz2 |
libmisc/shell/edit: Fix closing the editor
Closes #4564
-rw-r--r-- | cpukit/libmisc/shell/main_edit.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c index e43ff68d2b..586f33bd93 100644 --- a/cpukit/libmisc/shell/main_edit.c +++ b/cpukit/libmisc/shell/main_edit.c @@ -1789,14 +1789,14 @@ static void save_editor(struct editor *ed) { ed->refresh = 1; } -static void close_editor(struct editor *ed) { +static struct editor* close_editor(struct editor *ed) { struct env *env = ed->env; if (ed->dirty) { display_message(ed, "Close %s without saving changes (y/n)? ", ed->filename); if (!ask()) { ed->refresh = 1; - return; + return ed; } } @@ -1808,6 +1808,7 @@ static void close_editor(struct editor *ed) { new_file(ed, ""); } ed->refresh = 1; + return ed; } static void pipe_command(struct editor *ed) { @@ -2131,15 +2132,7 @@ static void edit(struct editor *ed) { case ctrl('s'): save_editor(ed); break; case ctrl('p'): pipe_command(ed); break; #endif -#if defined(__rtems__) - /* - * Coverity spotted this as using ed after free() so changing - * the order of the statements. - */ - case ctrl('w'): ed = ed->env->current; close_editor(ed); break; -#else - case ctrl('w'): close_editor(ed); ed = ed->env->current; break; -#endif + case ctrl('w'): ed = close_editor(ed); break; } } } |