0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

graphics-hook: Prevent recursive free

Make sure to set data.swap to null before calling data.free().
Otherwise, we may call data.free() again in the Release() hook.
This commit is contained in:
jpark37 2021-05-15 20:10:11 -07:00 committed by Jim
parent b899f06877
commit 32f9fc120a

View File

@ -100,12 +100,13 @@ static ULONG STDMETHODCALLTYPE hook_release(IUnknown *unknown)
rehook(&release);
if (unknown == data.swap && refs == 0) {
data.free();
data.swap = nullptr;
data.free = nullptr;
data.capture = nullptr;
dxgi_possible_swap_queue = nullptr;
dxgi_present_attempted = false;
data.free();
data.free = nullptr;
}
return refs;
@ -121,15 +122,15 @@ static HRESULT STDMETHODCALLTYPE hook_resize_buffers(IDXGISwapChain *swap,
{
HRESULT hr;
if (!!data.free)
data.free();
data.swap = nullptr;
data.free = nullptr;
data.capture = nullptr;
dxgi_possible_swap_queue = nullptr;
dxgi_present_attempted = false;
if (data.free)
data.free();
data.free = nullptr;
unhook(&resize_buffers);
resize_buffers_t call = (resize_buffers_t)resize_buffers.call_addr;
hr = call(swap, buffer_count, width, height, format, flags);