Do not leak filename_copy in case of error.
Catch out of memory when calling strdup.
Reported-by: Coverity (CID: 184086)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
char *filename_copy, *dirname, *basename;
filename_copy = strdup(filename);
+ if (!filename_copy) {
+ printf("Error: allocating memory\n");
+ ret = -ENOMEM;
+ goto exit;
+ }
split_filename(filename_copy, &dirname, &basename);
if (!strcmp(dirname, "/") && !strcmp(basename, "")) {
itr = malloc_cache_aligned(sizeof(fat_itr));
if (!itr) {
printf("Error: allocating memory\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto exit;
}
ret = fat_itr_root(itr, &fsdata);