diff --git a/Common/Buffer.cpp b/Common/Buffer.cpp index a7e02df8b0..74ec5b747d 100644 --- a/Common/Buffer.cpp +++ b/Common/Buffer.cpp @@ -136,7 +136,9 @@ bool Buffer::FlushToFile(const Path &filename, bool clear) { } void Buffer::PeekAll(std::string *dest) { - dest->resize(data_.size()); + // resize() here would leave that many zero bytes in front of the appended data. + dest->clear(); + dest->reserve(data_.size()); data_.iterate_blocks(([dest](const char *blockData, size_t blockSize) { dest->append(blockData, blockSize); return true; diff --git a/Common/Log.cpp b/Common/Log.cpp index 183a1721f7..f95bb7549c 100644 --- a/Common/Log.cpp +++ b/Common/Log.cpp @@ -136,8 +136,9 @@ bool HandleAssert(bool isDebugAssert, const char *function, const char *file, in const char *threadName = GetCurrentThreadName(); OutputDebugStringA(formatted); printf("%s\n", formatted); - static const std::string caption = isDebugAssert ? "Debug Assert" : "Critical Assert"; - std::wstring wcaption = ConvertUTF8ToWString(caption + " " + (threadName ? threadName : "(unknown thread)")); + // Not static - it'd freeze at whatever the first assert in the session was. + const char *caption = isDebugAssert ? "Debug Assert" : "Critical Assert"; + std::wstring wcaption = ConvertUTF8ToWString(std::string(caption) + " " + (threadName ? threadName : "(unknown thread)")); switch (MessageBox(g_dialogParent, ConvertUTF8ToWString(text).c_str(), wcaption.c_str(), msgBoxStyle)) { case IDYES: return true; diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp index 4bf4d1cdaa..23bb1626a3 100644 --- a/Common/StringUtils.cpp +++ b/Common/StringUtils.cpp @@ -86,7 +86,11 @@ long parseLong(std::string s) { } bool containsNoCase(std::string_view haystack, std::string_view needle) { - auto pred = [](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); }; + // toupper is UB for negative values other than EOF, and char is signed here - non-ASCII bytes + // reach this from e.g. ELF symbol names. + auto pred = [](char ch1, char ch2) { + return std::toupper((unsigned char)ch1) == std::toupper((unsigned char)ch2); + }; auto found = std::search(haystack.begin(), haystack.end(), needle.begin(), needle.end(), pred); return found != haystack.end(); } diff --git a/Core/TiltEventProcessor.cpp b/Core/TiltEventProcessor.cpp index ab093a578f..279fc6ff84 100644 --- a/Core/TiltEventProcessor.cpp +++ b/Core/TiltEventProcessor.cpp @@ -55,6 +55,13 @@ inline float ApplyDeadzoneAxis(float x, float deadzone) { inline void ApplyDeadzoneXY(float x, float y, float *adjustedX, float *adjustedY, float deadzone, bool circular) { if (circular) { + if (deadzone >= 0.99f) { + // Same guard as ApplyDeadzoneAxis - without it the factor below divides by ~0. + *adjustedX = x; + *adjustedY = y; + return; + } + if (x == 0.0f && y == 0.0f) { *adjustedX = 0.0f; *adjustedY = 0.0f;