diff options
author | sfan5 <sfan5@live.de> | 2022-10-14 15:44:57 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-10-14 15:47:49 +0200 |
commit | 9b541f29488f5f59cb1dd6edb54c91697e4d5172 (patch) | |
tree | fdb6b2687ae4359c8cc000ec996c32b5adbb723c /include/irrString.h | |
parent | 1cf0f3bef04e53c08004cc1106f48fcecca7ff88 (diff) | |
download | irrlicht-9b541f29488f5f59cb1dd6edb54c91697e4d5172.tar.xz |
Fix buffer size for wchar-multibyte conversion
Diffstat (limited to 'include/irrString.h')
-rw-r--r-- | include/irrString.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/irrString.h b/include/irrString.h index f454aed..d8757af 100644 --- a/include/irrString.h +++ b/include/irrString.h @@ -1503,12 +1503,12 @@ static size_t wStringToMultibyte(string<c8>& destination, const wchar_t* source, {
if ( sourceSize )
{
- destination.reserve(sourceSize+1);
+ destination.reserve(sizeof(wchar_t)*sourceSize+1);
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4996) // 'wcstombs': This function or variable may be unsafe. Consider using wcstombs_s instead.
#endif
- const size_t written = wcstombs(destination.array, source, (size_t)sourceSize);
+ const size_t written = wcstombs(destination.array, source, destination.allocated-1);
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
|