diff --git a/Code/Framework/AzCore/AzCore/std/string/conversions.h b/Code/Framework/AzCore/AzCore/std/string/conversions.h index 473c327143..c5c9b29cdb 100644 --- a/Code/Framework/AzCore/AzCore/std/string/conversions.h +++ b/Code/Framework/AzCore/AzCore/std/string/conversions.h @@ -338,9 +338,9 @@ namespace AZStd if (srcLen > 0) { char* endStr = Internal::WCharTPlatformConverter<>::to_string(dest, destSize, str, str + srcLen); - if (endStr < (dest + destSize) && *(endStr - 1) != '\0') + if (endStr < (dest + destSize)) { - *endStr = '\0'; // copy null terminator + *endStr = '\0'; // null terminator } } } @@ -495,9 +495,9 @@ namespace AZStd if (srcLen > 0) { wchar_t* endWStr = Internal::WCharTPlatformConverter<>::to_wstring(dest, destSize, str, str + srcLen); - if (endWStr < (dest + destSize) && *(endWStr - 1) != '\0') + if (endWStr < (dest + destSize)) { - *endWStr = '\0'; // copy null terminator + *endWStr = '\0'; // null terminator } } } diff --git a/Code/Framework/AzCore/Platform/Windows/AzCore/IPC/SharedMemory_Windows.cpp b/Code/Framework/AzCore/Platform/Windows/AzCore/IPC/SharedMemory_Windows.cpp index 20c126f7a8..d9149bdb44 100644 --- a/Code/Framework/AzCore/Platform/Windows/AzCore/IPC/SharedMemory_Windows.cpp +++ b/Code/Framework/AzCore/Platform/Windows/AzCore/IPC/SharedMemory_Windows.cpp @@ -31,6 +31,7 @@ namespace AZ SharedMemory_Common::CreateResult SharedMemory_Windows::Create(const char* name, unsigned int size, bool openIfCreated) { + azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name)); AZStd::fixed_wstring<256> fullName; ComposeName(fullName, name, L"Mutex"); @@ -67,6 +68,7 @@ namespace AZ bool SharedMemory_Windows::Open(const char* name) { + azstrncpy(m_name, AZ_ARRAY_SIZE(m_name), name, strlen(name)); AZStd::fixed_wstring<256> fullName; ComposeName(fullName, name, L"Mutex");