[PATCH 2/2] libmisc/shell/edit: Return if no memory in move_gap
chrisj at rtems.org
chrisj at rtems.org
Mon Jan 30 04:08:43 UTC 2023
From: Chris Johns <chrisj at rtems.org>
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;
--
2.37.1
More information about the devel
mailing list