From 28f2fb14682070bee1ab10a38828ad9e1637a9d9 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sun, 14 Jun 2020 13:32:04 +0300 Subject: [PATCH] emummc: Fix issue with emu_path corrupting bss --- bootloader/storage/emummc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bootloader/storage/emummc.c b/bootloader/storage/emummc.c index 763ffd5..2d9da61 100644 --- a/bootloader/storage/emummc.c +++ b/bootloader/storage/emummc.c @@ -29,21 +29,25 @@ #include "../utils/types.h" extern hekate_config h_cfg; -emummc_cfg_t emu_cfg; +emummc_cfg_t emu_cfg = { 0 }; void emummc_load_cfg() { emu_cfg.enabled = 0; emu_cfg.path = NULL; - emu_cfg.nintendo_path = NULL; emu_cfg.sector = 0; emu_cfg.id = 0; emu_cfg.file_based_part_size = 0; emu_cfg.active_part = 0; emu_cfg.fs_ver = 0; + if (!emu_cfg.nintendo_path) + emu_cfg.nintendo_path = (char *)malloc(0x80); if (!emu_cfg.emummc_file_based_path) emu_cfg.emummc_file_based_path = (char *)malloc(0x80); + emu_cfg.nintendo_path[0] = 0; + emu_cfg.emummc_file_based_path[0] = 0; + LIST_INIT(ini_sections); if (ini_parse(&ini_sections, "emuMMC/emummc.ini", false)) { @@ -65,7 +69,7 @@ void emummc_load_cfg() else if (!strcmp("path", kv->key)) emu_cfg.path = kv->val; else if (!strcmp("nintendo_path", kv->key)) - emu_cfg.nintendo_path = kv->val; + strcpy(emu_cfg.nintendo_path, kv->val); } break; } @@ -170,8 +174,10 @@ out: int emummc_storage_end(sdmmc_storage_t *storage) { - sd_end(); - sdmmc_storage_end(storage); + if (!emu_cfg.enabled || h_cfg.emummc_force_disable) + sdmmc_storage_end(storage); + else + sd_end(); return 1; }