Misc sanity checks

This commit is contained in:
Henrik Rydgård committed 2025-06-14 08:45:02 +02:00
1 parent aea6df0ca4
commit 70f1edb28f
8 files changed
+37 -18

No files matched your search

+7
View File
@@ -322,6 +322,10 @@ void ConvertUTF8ToJavaModifiedUTF8(std::string *output, std::string_view input)
output[out_idx++] = (char)0x80;
i++;
} else if ((c & 0xF0) == 0xF0) { // 4-byte sequence (U+10000 to U+10FFFF)
if (i + 4 > input.length()) {
// Bad.
break;
}
// Decode the Unicode code point from the UTF-8 sequence
uint32_t code_point = ((input[i] & 0x07) << 18) |
((input[i + 1] & 0x3F) << 12) |
@@ -345,6 +349,9 @@ void ConvertUTF8ToJavaModifiedUTF8(std::string *output, std::string_view input)
} else if ((c & 0xF0) == 0xE0) {
utf8_len = 3; // 3-byte sequence
}
if (i + utf8_len > input.length()) {
break;
}
memcpy(output->data() + out_idx, input.data() + i, utf8_len);
out_idx += utf8_len;
i += utf8_len;
+2 -2
View File
@@ -30,9 +30,9 @@ public:
return true;
uint32_t us = budget_s > 0 ? (uint32_t)(budget_s * 1000000.0) : 0;
if (us == 0)
if (us == 0) {
return false;
}
std::unique_lock<std::mutex> lock(mutex_);
return cond_.wait_for(lock, std::chrono::microseconds(us), [&] { return triggered_.load(); });
}
+4 -2
View File
@@ -313,8 +313,10 @@ void ScreenManager::sendMessage(UIMessage message, const char *value) {
// NOTE: Changed this to send the message to all screens, instead of just the top one,
// to allow EmuScreen to receive messages from popup menus. Hope this didn't break anything..
for (auto &iter : stack_) {
iter.screen->sendMessage(message, value);
for (const auto &iter : stack_) {
if (iter.screen) {
iter.screen->sendMessage(message, value);
}
}
}