From e7edbacd692ec688438eb7eef8ccb1cfd4647e29 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 17 Oct 2021 16:00:55 +0200 Subject: [PATCH] Fix invalid memory write in `StringUtils::ConvertANSI2UTF16` on Unix if length is empty --- Source/Engine/Platform/Unix/UnixStringUtils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Engine/Platform/Unix/UnixStringUtils.cpp b/Source/Engine/Platform/Unix/UnixStringUtils.cpp index c10fc8abb..28c63ed0c 100644 --- a/Source/Engine/Platform/Unix/UnixStringUtils.cpp +++ b/Source/Engine/Platform/Unix/UnixStringUtils.cpp @@ -313,6 +313,8 @@ static inline uint32 Utf8ToUtf32Codepoint(const char* src, int32 length) void StringUtils::ConvertANSI2UTF16(const char* from, Char* to, int32 len) { + if (len == 0) + return; const char* const u8end = from + len; const char* u8cur = from; char16_t* u16cur = to;