undo: prevent a use-after-free, reported by correctmost
When the cursor is on the last line, and an undo removes this line, do not let 'openfile->current' become invalid. This fixes https://savannah.gnu.org/bugs/?65279. Bug existed since version 6.3, commiteea3e1f0. (It should have been fixed in commit9410a556, more than a year ago.)
This commit is contained in:
@@ -436,6 +436,8 @@ void remove_magicline(void)
|
||||
{
|
||||
if (openfile->filebot->data[0] == '\0' &&
|
||||
openfile->filebot != openfile->filetop) {
|
||||
if (openfile->current == openfile->filebot)
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->filebot = openfile->filebot->prev;
|
||||
delete_node(openfile->filebot->next);
|
||||
openfile->filebot->next = NULL;
|
||||
|
||||
Reference in New Issue
Block a user