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

Chris Johns chrisj at rtems.org
Tue Jan 31 05:17:29 UTC 2023


Module:    rtems
Branch:    master
Commit:    edea93c40bd621d215d1ece07b9e43f255e8b420
Changeset: http://git.rtems.org/rtems/commit/?id=edea93c40bd621d215d1ece07b9e43f255e8b420

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 #4835

---

 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 b9e377bc23..6e954639e2 100644
--- a/cpukit/libmisc/shell/main_edit.c
+++ b/cpukit/libmisc/shell/main_edit.c
@@ -412,6 +412,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