From 162ce49af203d581e58f6989d161653cc8c1ce9c Mon Sep 17 00:00:00 2001 From: Turtle Dove Date: Mon, 13 Jul 2026 08:07:08 -0500 Subject: [PATCH] Backends: Vulkan: Fixed use-after-free in multi-viewport dynamic rendering path (#9390, #9468) --- backends/imgui_impl_vulkan.cpp | 5 ++++- docs/CHANGELOG.txt | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backends/imgui_impl_vulkan.cpp b/backends/imgui_impl_vulkan.cpp index 570b914c0..857e35820 100644 --- a/backends/imgui_impl_vulkan.cpp +++ b/backends/imgui_impl_vulkan.cpp @@ -29,6 +29,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) // 2026-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface. +// 2026-07-15: [Docking] Vulkan: fixed use-after-free when using multi-viewport with dynamic rendering path: deep-copy SurfaceFormat.format into the persistent buffer instead of storing a pointer to the viewport's wd->SurfaceFormat which dangles after the viewport is destroyed. (#9390, #9468) // 2026-04-23: Added support for standard draw callbacks (in platform_io): DrawCallback_ResetRenderState, DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest. (#9378) // 2026-04-22: *BREAKING CHANGE* redesigned to use separate ImageView + Sampler instead of Combined Image Sampler. This change allows us to facilitate changing samplers, in line with other backends. // - When registering custom textures: changed ImGui_ImplVulkan_AddTexture() signature to remove Sampler. @@ -2127,7 +2128,9 @@ static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport) { pipeline_info->PipelineRenderingCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO; pipeline_info->PipelineRenderingCreateInfo.colorAttachmentCount = 1; - pipeline_info->PipelineRenderingCreateInfo.pColorAttachmentFormats = &wd->SurfaceFormat.format; + bd->PipelineRenderingCreateInfoColorAttachmentFormats.resize(1); + bd->PipelineRenderingCreateInfoColorAttachmentFormats[0] = wd->SurfaceFormat.format; + pipeline_info->PipelineRenderingCreateInfo.pColorAttachmentFormats = bd->PipelineRenderingCreateInfoColorAttachmentFormats.Data; } else { diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 758276d98..41cbc3a0f 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -180,6 +180,8 @@ Docking+Viewports Branch: change when docked. (#9355, #9443) [@reybits] - Backends: - Metal4: added multi-viewport support. (#9465, #9451) [@hoffstadt] + - Vulkan: fixed use after-free when using multi-viewports with dynamic rendering. + (#9390, #9468) [@vikhik, @Turtle-PB] -----------------------------------------------------------------------