Misc correctness fixes

GetStringErrorMsg had the strerror_r result test backwards. The XSI variant returns
0 on success, so every successful lookup returned "Unknown error"; and under glibc
with _GNU_SOURCE the GNU variant is selected instead, which returns the message by
pointer and typically leaves the buffer untouched, so it returned an empty string.
Either way GetLastErrorMsg() was useless on Linux, Android and macOS. Pick the right
handling by overload resolution rather than guessing which signature we got.

KeyMap's "no gamepad button mapped to cancel" fallback pushed into confirmKeys
instead of cancelKeys - and pushed the confirm button. So unmapping cancel left no
gamepad way out of menus, and duplicated an entry in the confirm list.

ControlMapper::AddListener mutated listeners_ without taking mutex_, while
RemoveListener takes it and the input thread iterates the vector under it. Opening a
screen while an axis is moving could reallocate it mid-iteration. The comment about
piggybacking on a screenmanager mutex was stale - there isn't one.

Config's two std::stof calls on PostShaderSetting values ran on user-editable ini
text with no try/catch, so a malformed entry called std::terminate during startup
config load. Use the same checked sscanf that LoadGameConfig already uses.
(CmdLine.cpp and Compatibility.cpp have the same pattern; not touched here.)

The screenshot downscale path leaked its final buffer on every downscaled shot,
which savestate thumbnails hit on every save at 3x and above.

HandleUploadPost is registered unconditionally, so closing the Upload screen left an
unauthenticated file-write endpoint live for as long as anything else kept the server
up. Check the flag in the handler.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DCPmm7FoQUoqrbMdhfqhQ2
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-08-31 01:19:06 +02:00
1 parent e4a0f649fa
commit 375fa0fc11
7 files changed
+48 -14

No files matched your search

+13 -5
View File
@@ -25,6 +25,15 @@
#include "CommonWindows.h"
#else
#include <errno.h>
// See the comment at the call site.
static std::string StrErrorResult(char *result, const char *buf) {
return result ? result : "Unknown error";
}
static std::string StrErrorResult(int result, const char *buf) {
return result == 0 ? buf : "Unknown error";
}
#endif
// Generic function to get last error message.
@@ -60,10 +69,9 @@ std::string GetStringErrorMsg(int errCode) {
#else
char err_str[buff_size] = {};
// Thread safe (XSI-compliant)
if (strerror_r(errCode, err_str, buff_size) == 0) {
return "Unknown error";
}
return err_str;
// strerror_r has two incompatible signatures: the XSI one returns int (0 on success and the
// message is in the buffer), the GNU one returns a char * that may not be the buffer at all.
// Which one we get depends on _GNU_SOURCE, so let overload resolution sort it out.
return StrErrorResult(strerror_r(errCode, err_str, buff_size), err_str);
#endif
}