From 2e75c22759ad9f8d3b9f325079ef6543cac84b46 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@justemail.net> Date: Sat, 21 May 2016 21:29:54 +0200 Subject: [PATCH] browser: fix a memory leak --- src/browser.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/browser.c b/src/browser.c index 01e8f42f..47cce33c 100644 --- a/src/browser.c +++ b/src/browser.c @@ -380,12 +380,13 @@ char *do_browse_from(const char *inpath) path = mallocstrassn(path, striponedir(path)); if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) { - free(path); + char * currentdir = charalloc(PATH_MAX + 1); - path = charalloc(PATH_MAX + 1); - path = getcwd(path, PATH_MAX + 1); + free(path); + path = getcwd(currentdir, PATH_MAX + 1); if (path == NULL) { + free(currentdir); statusline(MILD, "The working directory has disappeared"); beep(); napms(1200); -- GitLab