The open source OpenXR runtime

c/client: Avoid double frees of timeline semaphore handles

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2071>

authored by

Charlton Rodda and committed by
korejan
adacf8a9 6ddfc57e

+9 -5
+5 -1
src/xrt/compositor/client/comp_d3d11_client.cpp
··· 776 776 } 777 777 D3D_INFO(c, "Native compositor created a timeline semaphore for us."); 778 778 779 + // Because importFence throws on failure we use this ref. 779 780 unique_compositor_semaphore_ref timeline_semaphore{xcsem}; 780 781 782 + // unique_compositor_semaphore_ref now owns the handle. 783 + HANDLE timeline_semaphore_handle_raw = timeline_semaphore_handle.release(); 784 + 781 785 // try to import and signal 782 - wil::com_ptr<ID3D11Fence> fence = import_fence(*(c->fence_device), timeline_semaphore_handle.get()); 786 + wil::com_ptr<ID3D11Fence> fence = import_fence(*(c->fence_device), timeline_semaphore_handle_raw); 783 787 HRESULT hr = c->fence_context->Signal(fence.get(), c->timeline_semaphore_value); 784 788 if (!SUCCEEDED(hr)) { 785 789 D3D_WARN(c,
+4 -4
src/xrt/compositor/client/comp_d3d12_client.cpp
··· 1040 1040 // Because importFence throws on failure we use this ref. 1041 1041 unique_compositor_semaphore_ref timeline_semaphore{xcsem}; 1042 1042 1043 + // unique_compositor_semaphore_ref now owns the handle. 1044 + HANDLE timeline_semaphore_handle_raw = timeline_semaphore_handle.release(); 1045 + 1043 1046 // Try to import, importFence throws on failure. 1044 1047 wil::com_ptr<ID3D12Fence1> fence = xrt::auxiliary::d3d::d3d12::importFence( // 1045 1048 *(c->device), // 1046 - timeline_semaphore_handle.get()); // 1047 - 1048 - // The fence now owns the handle., importFence throws on failure. 1049 - timeline_semaphore_handle.release(); 1049 + timeline_semaphore_handle_raw); // 1050 1050 1051 1051 // Check flags. 1052 1052 D3D12_FENCE_FLAGS flags = fence->GetCreationFlags();