From ca7718cb08e31f55ea62e8f3555f02fdba39aea1 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 2 Oct 2025 17:35:50 -0700 Subject: [PATCH] [glass] FMS: Fix reading past end of GSM buffer (#8268) --- glass/src/lib/native/cpp/other/FMS.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/glass/src/lib/native/cpp/other/FMS.cpp b/glass/src/lib/native/cpp/other/FMS.cpp index 86ed0205a7..22de23304b 100644 --- a/glass/src/lib/native/cpp/other/FMS.cpp +++ b/glass/src/lib/native/cpp/other/FMS.cpp @@ -148,11 +148,14 @@ void glass::DisplayFMSReadOnly(FMSModel* model) { ImGui::TextUnformatted("?"); } } - - wpi::SmallString<64> gameSpecificMessageBuf; - std::string_view gameSpecificMessage = - model->GetGameSpecificMessage(gameSpecificMessageBuf); - ImGui::Text("Game Specific: %s", exists ? gameSpecificMessage.data() : "?"); + if (exists) { + wpi::SmallString<64> gsmBuf; + std::string_view gsm = model->GetGameSpecificMessage(gsmBuf); + ImGui::Text("Game Specific: %.*s", static_cast(gsm.size()), + gsm.data()); + } else { + ImGui::TextUnformatted("Game Specific: ?"); + } if (!exists) { ImGui::PopStyleColor();