nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 6283557d2f1466e8f5ff6b0aebb419f395ba083a
parent af90f03ac5d8904cb004b7495a50224896dd6ccf
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri, 23 Apr 2021 12:20:45 +0200

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.

Diffstat:
Msrc/files.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -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 */