From 7354009a73a39ace4d7b1c3ef75403fb968812c4 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. (#5363, #5365) --- backends/imgui_impl_metal.mm | 8 ++++++-- docs/CHANGELOG.txt | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backends/imgui_impl_metal.mm b/backends/imgui_impl_metal.mm index 7023f43f..199a4c3a 100644 --- a/backends/imgui_impl_metal.mm +++ b/backends/imgui_impl_metal.mm @@ -12,6 +12,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2022-06-01: Metal: Fixed null dereference on exit inside command buffer completion handler. // 2022-04-27: Misc: Store backend data in a per-context struct, allowing to use this backend with multiple contexts. // 2022-01-03: Metal: Ignore ImDrawCmd where ElemCount == 0 (very rare but can technically be manufactured by user code). // 2021-12-30: Metal: Added Metal C++ support. Enable with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file. @@ -293,8 +294,11 @@ 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]; + } }); }]; } diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index cfadb88b..ed227d2a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -126,6 +126,7 @@ Other Changes: - Backends: OSX: Monitor NSKeyUp events to catch missing keyUp for key when user press Cmd + key (#5128) [@thedmd] - Backends: OSX, Metal: Store backend data in a per-context struct, allowing to use these backends with multiple contexts. (#5203, #5221, #4141) [@noisewuwei] +- Backends: Metal: Fixed null dereference on exit inside command buffer completion handler. (#5363, #5365) [@warrenm] - Backends: OpenGL3: Partially revert 1.86 change of using glBufferSubData(): now only done on Windows and Intel GPU, based on querying glGetString(GL_VENDOR). Essentially we got report of accumulating leaks on Intel with multi-viewports when using simple glBufferData() without orphaning, and report of corruptions on other