From 0720d59bb734901f3c6bf760341fedac83868fb1 Mon Sep 17 00:00:00 2001 From: ShiroKSH Date: Mon, 13 Jul 2026 21:34:14 +0300 Subject: [PATCH] Tables: validate ini settings column count. (#9472) + Amend with comment by ocornut. --- imgui_tables.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imgui_tables.cpp b/imgui_tables.cpp index e1328fe59..efc03d7d9 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -4165,9 +4165,12 @@ static void TableSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandle static void* TableSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name) { + // FIXME: As topology changes are allowed, strictly speaking a >= IMGUI_TABLE_MAX_COLUMNS tables stored in .ini file + // that was emitted with a higher max count could still be meaningful in some unlikely cases. + // We might want to use another MAX defined as (1<<(sizeof(ImGuiTableColumnIdx)*8-1))-1. ImGuiID id = 0; int columns_count = 0; - if (sscanf(name, "0x%08X,%d", &id, &columns_count) < 2) + if (sscanf(name, "0x%08X,%d", &id, &columns_count) < 2 || columns_count <= 0 || columns_count >= IMGUI_TABLE_MAX_COLUMNS) return NULL; return ImGui::TableSettingsCreate(id, columns_count); }