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

Closes #4835
This commit is contained in:
Chris Johns
2023-01-30 14:11:59 +11:00
parent 3ad2789fc6
commit edea93c40b

View File

@@ -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;