From d3dd403dc7565c3bd362996b3b602714a1e9e76b Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 24 Jul 2023 15:12:48 +0200 Subject: [PATCH] browser: report an error instead of crashing when the folder disappears When the directory that the user is browsing in is deleted by another process at the moment that nano is building the list of file names, this can result in an empty list, which some items in the main loop in browse() cannot handle. Prevent this mishandling by not entering the loop when the list is empty. This fixes https://savannah.gnu.org/bugs/?64465. Reported-by: Jerry Meng --- src/browser.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/browser.c b/src/browser.c index d569bb43..e5a4047c 100644 --- a/src/browser.c +++ b/src/browser.c @@ -436,7 +436,10 @@ char *browse(char *path) titlebar(path); - while (TRUE) { + if (list_length == 0) { + statusline(ALERT, _("No entries")); + napms(1200); + } else while (TRUE) { functionptrtype function; int kbinput;