From 92c1087adffd1ad5b6e27f355796d8908afbaa7e Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 21 Jul 2020 19:17:38 -0700 Subject: [PATCH] DS: Fix freeing memory for partial BIOS on load failure --- CHANGES | 1 + src/ds/ds.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index a98b797c4..0534d133d 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,7 @@ Bugfixes: - GBA Video: Fix regression adjusting brightness of backdrop - DS GX: Properly reject invalid commands - DS: Fix leaking BIOS and firmware filehandles + - DS: Fix freeing memory for partial BIOS on load failure Misc: - DS GX: Clean up and unify texture mapping - DS Core: Add symbol loading diff --git a/src/ds/ds.c b/src/ds/ds.c index 85ec8a187..8fdbd9629 100644 --- a/src/ds/ds.c +++ b/src/ds/ds.c @@ -597,7 +597,11 @@ bool DSLoadBIOS(struct DS* ds, struct VFile* vf) { mLOG(DS, INFO, "Official DS ARM9 BIOS detected"); } else { mLOG(DS, WARN, "BIOS checksum incorrect"); - vf->unmap(vf, data, size); + if (size == 0x1000) { + free(data); + } else { + vf->unmap(vf, data, size); + } return false; } return true;