[rtems commit] libmisc/shell/edit: Return if no memory in move_gap

Chris Johns chrisj at rtems.org
Tue Feb 14 05:06:13 UTC 2023


Module:    rtems
Branch:    refs/tags/5.3
Commit:    b7f1fa2f89244347472fa1f6829287bcab285730
Changeset: http://git.rtems.org/rtems/commit/?id=b7f1fa2f89244347472fa1f6829287bcab285730

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Jan 30 14:11:59 2023 +1100

libmisc/shell/edit: Return if no memory in move_gap

Closes #4565

---

 cpukit/libmisc/shell/main_edit.c | 3 +++
 1 file changed, 3 insertions(+)

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;



More information about the vc mailing list