diff --git a/src/browser.c b/src/browser.c index 87e8205..0c075a6 100644 --- a/src/browser.c +++ b/src/browser.c @@ -123,9 +123,6 @@ char *do_browser(char *path) while (TRUE) { struct stat st; int i; - char *new_path; - /* The path we switch to at the "Go to Directory" - * prompt. */ /* Make sure that the cursor is off. */ curs_set(0); @@ -259,37 +256,25 @@ char *do_browser(char *path) sunder(answer); align(&answer); - new_path = real_dir_from_tilde(answer); + newpath = real_dir_from_tilde(answer); - if (new_path[0] != '/') { - new_path = charealloc(new_path, strlen(path) + + if (newpath[0] != '/') { + newpath = charealloc(newpath, strlen(path) + strlen(answer) + 1); - sprintf(new_path, "%s%s", path, answer); + sprintf(newpath, "%s%s", path, answer); } #ifndef DISABLE_OPERATINGDIR - if (check_operating_dir(new_path, FALSE)) { + if (check_operating_dir(newpath, FALSE)) { /* TRANSLATORS: This refers to the option --operatingdir, * not to --restricted. */ statusline(ALERT, _("Can't go outside of %s " "in confined mode"), full_operating_dir); - free(new_path); + free(newpath); continue; } #endif - - dir = opendir(new_path); - if (dir == NULL) { - /* We can't open this directory for some reason. */ - statusline(ALERT, _("Error reading %s: %s"), answer, - strerror(errno)); - free(new_path); - continue; - } - - /* Start over again with the new path value. */ - free(path); - path = new_path; + /* Try opening and reading the entered directory, in newpath. */ goto read_directory_contents; } else if (func == do_up_void) { if (selected >= width)