From f6b41187cc57d660a47228d96d4b33fb5794cd67 Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Wed, 30 Apr 2025 17:16:06 +0200 Subject: [PATCH] RMG-COre: try to fix str size in CoreGetCUrrentRomHeader() (TODO: test) --- Source/RMG-Core/RomHeader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/RMG-Core/RomHeader.cpp b/Source/RMG-Core/RomHeader.cpp index b049bdff..ad9a7c59 100644 --- a/Source/RMG-Core/RomHeader.cpp +++ b/Source/RMG-Core/RomHeader.cpp @@ -12,6 +12,7 @@ #else // Unix #include #endif // _WIN32 +#include #define CORE_INTERNAL #include "ConvertStringEncoding.hpp" @@ -168,13 +169,19 @@ CORE_EXPORT bool CoreGetCurrentRomHeader(CoreRomHeader& header) return false; } + printf("header name len: %i\n", strlen((char*)m64p_header.Name)); + header.CRC1 = ntohl(m64p_header.CRC1); header.CRC2 = ntohl(m64p_header.CRC2); header.CountryCode = m64p_header.Country_code; - header.Name = CoreConvertStringEncoding(std::string(reinterpret_cast(m64p_header.Name), 20), CoreStringEncoding::Shift_JIS); + header.Name = CoreConvertStringEncoding(std::string(reinterpret_cast(m64p_header.Name), + std::min(std::strlen(reinterpret_cast(m64p_header.Name)), static_cast(20))), + CoreStringEncoding::Shift_JIS); header.GameID = get_gameid_from_header(m64p_header); header.Region = get_region_from_countrycode(static_cast(header.CountryCode)); header.SystemType = get_systemtype_from_countrycode(header.CountryCode); + printf("header name len after: %i\n", header.Name.size()); + return true; }