From e82a6eb990f995c0112509a2505eb25a014fe301 Mon Sep 17 00:00:00 2001 From: Warren Moore Date: Tue, 31 May 2022 15:06:42 -0700 Subject: [PATCH] Backends: Metal: Fixed null dereference inside command buffer completion handler --- backends/imgui_impl_metal.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backends/imgui_impl_metal.mm b/backends/imgui_impl_metal.mm index 7023f43ff9b6..ca63ed723755 100644 --- a/backends/imgui_impl_metal.mm +++ b/backends/imgui_impl_metal.mm @@ -293,8 +293,10 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData, id c { dispatch_async(dispatch_get_main_queue(), ^{ ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData(); - [bd->SharedMetalContext.bufferCache addObject:vertexBuffer]; - [bd->SharedMetalContext.bufferCache addObject:indexBuffer]; + if (bd != NULL) { + [bd->SharedMetalContext.bufferCache addObject:vertexBuffer]; + [bd->SharedMetalContext.bufferCache addObject:indexBuffer]; + } }); }]; }