Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
Stop loading themes missing smdh files - this was causing scroll crashes due to how the icon loading code was working. In the future we will include a message about how themes are skipped due to lacking smdh files. Invalid zips also caused the same issue and are also now being properly ignored

Fix memory leak in the zip file loading code
  • Loading branch information
astronautlevel2 committed Jun 12, 2020
1 parent 2c2c7f4 commit a4532b0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ u32 zip_file_to_buf(char *file_name, u16 *zip_path, char **buf)
archive_read_support_format_zip(a);

int r = archive_read_open_filename(a, path, 0x4000);
free(path);
if(r != ARCHIVE_OK)
{
DEBUG("Invalid zip being opened\n");
Expand Down
22 changes: 20 additions & 2 deletions source/loading.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,27 @@ Result load_entries(const char * loading_path, Entry_List_s * list)
if(R_FAILED(res) || entries_read == 0)
break;

if(!(dir_entry.attributes & FS_ATTRIBUTE_DIRECTORY) && strcmp(dir_entry.shortExt, "ZIP"))
if(!(dir_entry.attributes & FS_ATTRIBUTE_DIRECTORY) && strcmp(dir_entry.shortExt, "ZIP"))
continue;

u16 path[0x106] = {0};
struacat(path, loading_path);
strucat(path, dir_entry.name);
char * buf = NULL;

if (!strcmp(dir_entry.shortExt, "ZIP"))
{
u32 size = zip_file_to_buf("info.smdh", path, &buf);
if (size == 0) continue;
}
else
{
struacat(path, "/info.smdh");
u32 size = file_to_buf(fsMakePath(PATH_UTF16, path), ArchiveSD, &buf);
if (size == 0) continue;
}

free(buf);
list->entries_count++;
Entry_s * new_list = realloc(list->entries, list->entries_count * sizeof(Entry_s));
if(new_list == NULL)
Expand Down Expand Up @@ -645,4 +663,4 @@ Result load_audio(Entry_s entry, audio_s *audio)
DEBUG("<load_audio> fmemopen failed!\n");
return MAKERESULT(RL_FATAL, RS_NOTFOUND, RM_APPLICATION, RD_NOT_FOUND);
}
}
}

0 comments on commit a4532b0

Please sign in to comment.