From bd10c2ea292fa7cb5f8f25f02316d700eee36df0 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Mon, 16 Mar 2026 18:49:33 +0000 Subject: [PATCH] Free resources for Nintendo GameCube/Wii junk map and Wii encryption contexts: implement cleanup in close function --- src/close.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/close.c b/src/close.c index 3651062..938ece9 100644 --- a/src/close.c +++ b/src/close.c @@ -5316,6 +5316,32 @@ AARU_EXPORT int AARU_CALL aaruf_close(void *context) ctx->wiiu_encrypted_block_cache = NULL; ctx->wiiu_cache_valid = false; + // Free Nintendo GC/Wii junk map context + if(ctx->ngcw_junk_entries != NULL) + { + free(ctx->ngcw_junk_entries); + ctx->ngcw_junk_entries = NULL; + } + ctx->ngcw_junk_entry_count = 0; + ctx->ngcw_junk_seed_size = 0; + ctx->ngcw_junk_initialized = false; + + // Free Wii encryption context + if(ctx->wii_partition_regions != NULL) + { + // Wipe keys from partition regions before freeing + uint32_t wii_count = ctx->wii_partition_region_count; + uint8_t *wii_region = (uint8_t *)ctx->wii_partition_regions; + memset(wii_region, 0, wii_count * 24); + free(ctx->wii_partition_regions); + ctx->wii_partition_regions = NULL; + } + ctx->wii_partition_region_count = 0; + ctx->wii_encryption_initialized = false; + free(ctx->wii_encrypted_group_cache); + ctx->wii_encrypted_group_cache = NULL; + ctx->wii_cache_valid = false; + free(ctx->sector_id); free(ctx->sector_ied); free(ctx->sector_cpr_mai);