[olympic,nostalgia] Address unsafe buffer warnings

This commit is contained in:
2025-05-06 22:25:36 -05:00
parent a8c1387d5a
commit d8195d300d
15 changed files with 55 additions and 42 deletions

View File

@ -44,10 +44,10 @@ static ox::Result<std::size_t> findPreloadSection() noexcept {
// media section
constexpr auto headerP2 = "DER_____________";
constexpr auto headerP1 = "KEEL_PRELOAD_HEA";
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
constexpr auto headerP1Len = ox::strlen(headerP2);
constexpr auto headerP2Len = ox::strlen(headerP1);
constexpr auto headerLen = headerP1Len + headerP2Len;
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
for (auto current = MEM_ROM; current < reinterpret_cast<char*>(0x0a000000); current += headerLen) {
if (memcmp(current, headerP1, headerP1Len) == 0 &&
memcmp(current + headerP1Len, headerP2, headerP2Len) == 0) {

View File

@ -18,7 +18,9 @@ ox::String getClipboardText(Context &ctx) noexcept {
void setClipboardText(Context &ctx, ox::StringViewCR text) noexcept {
auto cstr = ox_malloca(text.bytes() + 1, char);
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
ox::strncpy(cstr.get(), text.data(), text.bytes());
OX_ALLOW_UNSAFE_BUFFERS_END
glfwSetClipboardString(ctx.window, cstr.get());
}

View File

@ -267,7 +267,9 @@ ox::Error setWindowIcon(Context &ctx, ox::SpanView<ox::SpanView<uint8_t>> const
void setWindowTitle(Context &ctx, ox::StringViewCR title) noexcept {
auto cstr = ox_malloca(title.bytes() + 1, char);
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
ox::strncpy(cstr.get(), title.data(), title.bytes());
OX_ALLOW_UNSAFE_BUFFERS_END
glfwSetWindowTitle(ctx.window, cstr.get());
}