From 1c6e802cf95a32d33f403105bf7cfcec03854eb6 Mon Sep 17 00:00:00 2001 From: Marcel Rodrigues Date: Sun, 19 Feb 2017 11:25:37 -0300 Subject: [PATCH] Don't assume CWD is a valid path. --- rover.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rover.c b/rover.c index 46697de..95a6297 100644 --- a/rover.c +++ b/rover.c @@ -646,8 +646,11 @@ cd(int reset) message(CYAN, "Loading \"%s\"...", CWD); refresh(); + if (chdir(CWD) == -1) { + getcwd(CWD, PATH_MAX-1); + goto done; + } if (reset) ESEL = SCROLL = 0; - chdir(CWD); if (rover.nfiles) free_rows(&rover.rows, rover.nfiles); rover.nfiles = ls(&rover.rows, FLAGS); @@ -664,6 +667,7 @@ cd(int reset) } else for (i = 0; i < rover.nfiles; i++) MARKED(i) = 0; +done: clear_message(); update_view(); } -- 2.11.4.GIT