summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEblo <7004497+Eblo@users.noreply.github.com>2026-07-24 13:07:35 -0400
committerGitHub <noreply@github.com>2026-07-24 13:07:35 -0400
commitf59f1a5948be7227b6192ff8b6037207b7c415ff (patch)
tree309eb612e99f71600006e6b27cc4d483f9fb6c0e
parentbca14bef11f449de27a8276ddfbeac535f3d4058 (diff)
Fix OOB crash with randoinf flag editor (#1808)
-rw-r--r--mm/2s2h/BenGui/UIWidgets.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/2s2h/BenGui/UIWidgets.cpp b/mm/2s2h/BenGui/UIWidgets.cpp
index c6c4c2ea7..d13fdbc14 100644
--- a/mm/2s2h/BenGui/UIWidgets.cpp
+++ b/mm/2s2h/BenGui/UIWidgets.cpp
@@ -1226,13 +1226,18 @@ template <typename T> static void DrawFlagTableArrayRowImpl(const FlagTable& fla
constexpr int16_t width = sizeof(T) * 8;
ImGui::PushID(flagTable.name);
for (int16_t flagIndex = 0; flagIndex < width; flagIndex++) {
+ size_t flagEntryIndex = row * width + flagIndex;
+ if (flagEntryIndex >= flagTable.entries.size()) {
+ break;
+ }
+
if (flagIndex != 0) {
ImGui::SameLine();
}
ImGui::PushID(flagIndex);
T bitMask = 1 << flagIndex;
bool flag = (flags & bitMask) != 0;
- FlagEntry flagEntry = flagTable.entries.at(row * width + flagIndex);
+ FlagEntry flagEntry = flagTable.entries.at(flagEntryIndex);
PushStyleCheckbox(LightBlue);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4.0f, 6.0f));
std::string id = fmt::format("####{}", flagIndex);