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

Closes #4565
This commit is contained in:
Chris Johns
2023-01-30 14:11:59 +11:00
parent 45f60cfbcf
commit b7f1fa2f89

View File

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