summaryrefslogtreecommitdiffstats
path: root/libmenu/menu_filesel.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmenu/menu_filesel.c')
-rw-r--r--libmenu/menu_filesel.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c
index d656c11c70..b0643deaf5 100644
--- a/libmenu/menu_filesel.c
+++ b/libmenu/menu_filesel.c
@@ -390,7 +390,7 @@ static void clos(menu_t* menu) {
}
static int open_fs(menu_t* menu, char* args) {
- char *path = mpriv->path, *freepath = NULL;
+ char *path = mpriv->path;
int r = 0;
char wd[PATH_MAX+1], b[PATH_MAX+1];
args = NULL; // Warning kill
@@ -409,12 +409,9 @@ static int open_fs(menu_t* menu, char* args) {
if (path_fp >= 0) {
if (!fstat (path_fp, &st) && (st.st_size > 0)) {
path = malloc(st.st_size+1);
- if ((read(path_fp, path, st.st_size) == st.st_size) && path[0] == '/'
- && !stat(path, &st) && S_ISDIR(st.st_mode)){
- freepath = path;
- path[st.st_size] = '\0';
- }
- else {
+ path[st.st_size] = '\0';
+ if (!((read(path_fp, path, st.st_size) == st.st_size) && path[0] == '/'
+ && !stat(path, &st) && S_ISDIR(st.st_mode))) {
free(path);
path = NULL;
}
@@ -467,9 +464,6 @@ static int open_fs(menu_t* menu, char* args) {
}
r = open_dir(menu,path);
- if (freepath)
- free(freepath);
-
return r;
}