From 2b0bdc361f893664bf0b70cef6dcf08a7db1de03 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 27 Nov 2015 17:36:34 +0100 Subject: [PATCH] State: Don't use memcpy and memcmp with strings --- Source/Core/Core/State.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index c14c9dc9ef..c7c3110961 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -343,7 +343,7 @@ static void CompressAndDumpState(CompressAndDumpState_args save_args) // Setting up the header StateHeader header; - memcpy(header.gameID, SConfig::GetInstance().GetUniqueID().c_str(), 6); + strncpy((char*)header.gameID, SConfig::GetInstance().GetUniqueID().c_str(), 6); header.size = g_use_compression ? (u32)buffer_size : 0; header.time = Common::Timer::GetDoubleTime(); @@ -474,7 +474,7 @@ static void LoadFileStateData(const std::string& filename, std::vector& ret_ StateHeader header; f.ReadArray(&header, 1); - if (memcmp(SConfig::GetInstance().GetUniqueID().c_str(), header.gameID, 6)) + if (strncmp(SConfig::GetInstance().GetUniqueID().c_str(), (char*)header.gameID, 6)) { Core::DisplayMessage(StringFromFormat("State belongs to a different game (ID %.*s)", 6, header.gameID), 2000);