diff options
| author | Killyana <morphone1@gmail.com> | 2019-01-12 12:16:23 +0100 | 
|---|---|---|
| committer | Killyana <morphone1@gmail.com> | 2019-01-12 12:16:23 +0100 | 
| commit | 9faad4601bc633036c469aefc82db49eab36e5ea (patch) | |
| tree | af5cb95a2b5b6134e740dfe6cf27792771b2cb60 | |
| parent | dc16cf89b7205288f30291a6f62289cf48d14528 (diff) | |
| parent | bdb7e6e5e81e0d9376c9c803bae9da470b02d8cd (diff) | |
Merge branch '3.3.5' of https://github.com/TrinityCore/TrinityCore into 3.3.5
| -rw-r--r-- | src/common/Utilities/Util.cpp | 18 | 
1 files changed, 16 insertions, 2 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index ad042ab216c..3735cca089f 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -260,9 +260,23 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)      }      catch(std::exception)      { -        if (wsize > 0) +        // Replace the converted string with an error message if there is enough space +        // Otherwise just return an empty string +        wchar_t const* errorMessage = L"An error occurred converting string from UTF-8 to WStr"; +        size_t errorMessageLength = wcslen(errorMessage); +        if (wsize >= errorMessageLength) +        { +            wcscpy(wstr, errorMessage); +            wsize = wcslen(wstr); +        } +        else if (wsize > 0) +        {              wstr[0] = L'\0'; -        wsize = 0; +            wsize = 0; +        } +        else +            wsize = 0; +          return false;      }  | 
