summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2023-01-30 14:11:59 +1100
committerChris Johns <chrisj@rtems.org>2023-01-30 14:11:59 +1100
commitb7f1fa2f89244347472fa1f6829287bcab285730 (patch)
tree231ec7b1079b0bea41d7e5478fbf86e6d260f9fb
parentlibmisc/shell/edit: Fix closing the editor (diff)
downloadrtems-5.tar.bz2
libmisc/shell/edit: Return if no memory in move_gap5.35
Closes #4565
-rw-r--r--cpukit/libmisc/shell/main_edit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c
index 586f33bd93..681e8c5f3c 100644
--- a/cpukit/libmisc/shell/main_edit.c
+++ b/cpukit/libmisc/shell/main_edit.c
@@ -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;