diff --git a/src/fs/fugue/fugue_dir.c b/src/fs/fugue/fugue_dir.c index b2c1971..d8a8fc0 100644 --- a/src/fs/fugue/fugue_dir.c +++ b/src/fs/fugue/fugue_dir.c @@ -118,7 +118,7 @@ void *fugue_dir_explore(char const *path) if(rc < 0) { if(rc != BFile_EntryNotFound) errno = bfile_error_to_errno(rc); - goto end; + goto error; } do { @@ -148,6 +148,7 @@ void *fugue_dir_explore(char const *path) alloc_failure: errno = ENOMEM; +error: fugue_dir_close(dp); dp = NULL; end: diff --git a/src/fs/fugue/fugue_open.c b/src/fs/fugue/fugue_open.c index 8ecafea..c9ecce4 100644 --- a/src/fs/fugue/fugue_open.c +++ b/src/fs/fugue/fugue_open.c @@ -63,6 +63,10 @@ int fugue_open(char const *path, int flags, GUNUSED mode_t mode) /* If the entry is a directory, open it as such */ if(type == BFile_Type_Directory) { void *dp = fugue_dir_explore(path); + if(!dp) { + rc = -1; + goto end; + } fs_descriptor_t data = { .type = &fugue_dir_descriptor_type, .data = dp,