Try changing the call to
vswprintf_s(str, sizeof(str)/sizeof(wchar_t), first, marker);
You're operating on the wrong size. wchar_t
doesn't have char
's guaranteed of being 1 in size.
Question
When running our game in debug-mode I get a buffer overrun crash - the callstack is bananas (looks like it's stuck in a recursive loop) however I tracked the crash to the following function:
std::wstring formatWstring(const wchar_t *first, ...)
{
wchar_t str[4096];
va_list marker;
va_start(marker, first);
vswprintf_s(str, sizeof(str), first, marker);
va_end(marker);
return str;
}
which is called in the following fashion:
std::wstring gmh = io::lexicon->getString("FE_gamemode_header");
std::wstring gms = io::lexicon->getString(formatString("FE_gamemode_%s", game->getCurrentMapGameMode().c_str()));
m_gameMode = formatWstring(L"%S: %S", gmh.c_str(), gms.c_str());
I can't seem to figure out what's blowing this up.. any clues?
Solution
Try changing the call to
vswprintf_s(str, sizeof(str)/sizeof(wchar_t), first, marker);
You're operating on the wrong size. wchar_t
doesn't have char
's guaranteed of being 1 in size.