diff --git a/src/browser.c b/src/browser.c index 23916b4..803dab3 100644 --- a/src/browser.c +++ b/src/browser.c @@ -115,6 +115,7 @@ char *do_browser(char *path) old_selected = (size_t)-1; + free(newpath); newpath = NULL; present_path = mallocstrcpy(present_path, path); @@ -338,7 +339,7 @@ char *do_browser(char *path) present_name = striponedir(filelist[selected]); /* Try opening and reading the selected directory. */ - newpath = filelist[selected]; + newpath = strdup(filelist[selected]); goto read_directory_contents; } else if (func == do_exit) { /* Exit from the file browser. */