mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-20 17:59:08 +02:00
Fix the latent tail from the Common/Core review
Buffer::PeekAll resized the destination and then appended, so it returned twice the data with zeros in front. No callers today. The assert dialog's caption was a function-local static, so it froze at whichever kind of assert fired first in the session - a later Critical Assert would still be titled 'Debug Assert'. Made it a plain const char *. containsNoCase passed a possibly-negative char to std::toupper, which is UB for anything but EOF; non-ASCII bytes get here from ELF symbol names. ApplyDeadzoneXY's circular path lacked the deadzone >= 0.99f guard its own sibling ApplyDeadzoneAxis has one function above, so it divided by ~0.
This commit is contained in:
1 parent
49552b0881
commit
ab0fa898ae
4 files changed
+18
-4
No files matched your search
+3
-1
@@ -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;
|
||||
|
||||
+3
-2
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user