From 3aa9aae0be474dfd77281a2aca1f3a69542b9b44 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 1 Aug 2019 15:50:05 -0700 Subject: [PATCH] Docking: Fix a crash that could occur with a malformed ini file (DockNode Parent value pointing to a missing node) --- imgui.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index efba7301..eaecd43b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11426,13 +11426,14 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx) } // Count reference to dock ids from window settings + // We guard against the possibility of an invalid .ini file (RootID may point to a missing node) for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++) if (ImGuiID dock_id = g.SettingsWindows[settings_n].DockId) if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(dock_id)) { - ImGuiDockContextPruneNodeData* data_root = (data->RootID == dock_id) ? data : pool.GetByKey(data->RootID); data->CountWindows++; - data_root->CountChildWindows++; + if (ImGuiDockContextPruneNodeData* data_root = (data->RootID == dock_id) ? data : pool.GetByKey(data->RootID)) + data_root->CountChildWindows++; } // Prune