From 2afe8e7331fda588074336e6d60cbcd98bfe9db8 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Sat, 3 Jan 2026 22:21:11 +0000 Subject: [PATCH] Fix string conversion utilities crashing on null input --- .../Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp index fedf8d86988..04f604a98ea 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp @@ -32,6 +32,11 @@ std::wstring MultiByteToWideCharSingleLine( const char *orig ) { + std::wstring ret; + if (orig == NULL) + { + return ret; + } Int len = strlen(orig); WideChar *dest = NEW WideChar[len+1]; @@ -57,7 +62,7 @@ std::wstring MultiByteToWideCharSingleLine( const char *orig ) while ( c != NULL ); dest[len] = 0; - std::wstring ret = dest; + ret = dest; delete[] dest; return ret; } @@ -65,6 +70,10 @@ std::wstring MultiByteToWideCharSingleLine( const char *orig ) std::string WideCharStringToMultiByte( const WideChar *orig ) { std::string ret; + if (orig == NULL) + { + return ret; + } Int len = WideCharToMultiByte( CP_UTF8, 0, orig, wcslen(orig), NULL, 0, NULL, NULL ) + 1; if (len > 0) {