fs: fix incorrect OoM handling in fugue_dir_explore()

Non-NULL dp would be returned by alloc failure path despite having been
freed.
This commit is contained in:
Lephe 2024-02-04 18:17:41 +01:00
parent caa68b08bf
commit 1e220af616
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 3 additions and 2 deletions

View File

@ -93,6 +93,8 @@ void *fugue_dir_explore(char const *path)
struct BFile_FileInfo info;
char *wildcard=NULL;
uint16_t *fc_path=NULL, *search=NULL;
/* We allocate by batches of 8 */
int sd=-1, rc, allocated=0;
dir_t *dp = malloc(sizeof *dp);
if(!dp) goto alloc_failure;
@ -100,8 +102,6 @@ void *fugue_dir_explore(char const *path)
dp->count = 0;
dp->entries = NULL;
dp->pos = 0;
/* We allocate by batches of 8 */
int sd=-1, rc, allocated=0;
fc_path = malloc(512 * sizeof *fc_path);
if(!fc_path) goto alloc_failure;
@ -149,6 +149,7 @@ void *fugue_dir_explore(char const *path)
alloc_failure:
errno = ENOMEM;
fugue_dir_close(dp);
dp = NULL;
end:
free(wildcard);
free(search);