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 <jerrytstng@gmail.com>
This commit is contained in:
Benno Schulenberg 2023-07-24 15:12:48 +02:00
parent 7f4c2c6a25
commit d3dd403dc7

View File

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