memory: prevent a use-after-free when the user respects a lock file

This fixes https://savannah.gnu.org/bugs/?60447.

Bug existed since commit 2f718e11 from a month ago.
This commit is contained in:
Benno Schulenberg 2021-04-23 12:20:45 +02:00
parent af90f03ac5
commit 6283557d2f

View File

@ -603,14 +603,14 @@ void close_buffer(void)
free(orphan->errormessage);
openfile = orphan->prev;
if (openfile == orphan)
openfile = NULL;
free(orphan);
/* When just one buffer remains open, show "Exit" in the help lines. */
if (openfile == openfile->next)
if (openfile && openfile == openfile->next)
exitfunc->desc = exit_tag;
if (openfile == orphan)
openfile = NULL;
}
#endif /* ENABLE_MULTIBUFFER */