From 4c43ef030de7d94f2e72e9c53b9e37beed503850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= <159546+serprex@users.noreply.github.com> Date: Mon, 17 Aug 2026 17:23:08 +0000 Subject: [PATCH] Fix crash when loading unversioned oot_save.sav (#7090) --- soh/soh/SaveManager.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index d94f8be106..af0f746645 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -2799,11 +2799,17 @@ void SaveManager::ConvertFromUnversioned() { #define SLOT_SIZE (sizeof(SaveContext_v0) + 0x28) #define SLOT_OFFSET(index) (SRAM_HEADER_SIZE + 0x10 + (index * SLOT_SIZE)) - std::ifstream input("oot_save.sav", std::ios::binary); + std::ifstream input(Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav"), std::ios::binary); std::vector data(std::istreambuf_iterator(input), {}); input.close(); + // Couldn't read the file, or it's too short to hold all three slots + if (data.size() < SLOT_OFFSET(3)) { + CreateDefaultGlobal(); + return; + } + for (size_t i = 0; i < ARRAY_COUNT(sZeldaMagic) - 3; i++) { if (sZeldaMagic[i + SRAM_HEADER_MAGIC] != data[i + SRAM_HEADER_MAGIC]) { CreateDefaultGlobal();