Compare commits

...

3 Commits
5.2 ... 5.3

Author SHA1 Message Date
Chris Johns
b7f1fa2f89 libmisc/shell/edit: Return if no memory in move_gap
Closes #4565
2023-01-30 14:11:59 +11:00
Chris Johns
45f60cfbcf libmisc/shell/edit: Fix closing the editor
Closes #4564
2023-01-30 13:59:11 +11:00
Chris Johns
2243fd6d6b libmisc/shell/chmod: Fix multiple file arguments to the command
Closes #4558
2023-01-30 13:37:42 +11:00
2 changed files with 8 additions and 12 deletions

View File

@@ -53,7 +53,7 @@ static int rtems_shell_main_chmod(
* Now change the files modes
*/
for (n=2 ; n < argc ; n++)
chmod(argv[n++], mode);
chmod(argv[n], mode);
return 0;
}

View File

@@ -407,6 +407,9 @@ static void move_gap(struct editor *ed, int pos, int minsize) {
if (gapsize + MINEXTEND > minsize) minsize = gapsize + MINEXTEND;
newsize = (ed->end - ed->start) - gapsize + minsize;
start = (unsigned char *) malloc(newsize); // TODO check for out of memory
if (start == NULL) {
return;
}
gap = start + pos;
rest = gap + minsize;
end = start + newsize;
@@ -1789,14 +1792,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 +1811,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 +2135,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;
}
}
}