Module: wine Branch: master Commit: e1983836b7ce8f7e47d87d756c986e72f247e7e1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=e1983836b7ce8f7e47d87d756c...
Author: Józef Kucia jkucia@codeweavers.com Date: Thu Jul 20 14:11:04 2017 +0200
d3d11: Fix race condition in d3d_sampler_state_create().
Spotted by Kimmo Myllyvirta.
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d3d11/state.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 64fae13..b7c9264 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -1441,7 +1441,6 @@ static HRESULT d3d_sampler_state_init(struct d3d_sampler_state *state, struct d3 state->ID3D11SamplerState_iface.lpVtbl = &d3d11_sampler_state_vtbl; state->ID3D10SamplerState_iface.lpVtbl = &d3d10_sampler_state_vtbl; state->refcount = 1; - wined3d_mutex_lock(); wined3d_private_store_init(&state->private_store); state->desc = *desc;
@@ -1465,7 +1464,6 @@ static HRESULT d3d_sampler_state_init(struct d3d_sampler_state *state, struct d3 { ERR("Failed to insert sampler state entry.\n"); wined3d_private_store_cleanup(&state->private_store); - wined3d_mutex_unlock(); return E_FAIL; }
@@ -1477,10 +1475,8 @@ static HRESULT d3d_sampler_state_init(struct d3d_sampler_state *state, struct d3 WARN("Failed to create wined3d sampler, hr %#x.\n", hr); wined3d_private_store_cleanup(&state->private_store); wine_rb_remove(&device->sampler_states, &state->entry); - wined3d_mutex_unlock(); return hr; } - wined3d_mutex_unlock();
state->device = &device->ID3D11Device_iface; ID3D11Device_AddRef(state->device); @@ -1521,12 +1517,16 @@ HRESULT d3d_sampler_state_create(struct d3d_device *device, const D3D11_SAMPLER_
return S_OK; } - wined3d_mutex_unlock();
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + { + wined3d_mutex_unlock(); return E_OUTOFMEMORY; + }
- if (FAILED(hr = d3d_sampler_state_init(object, device, &normalized_desc))) + hr = d3d_sampler_state_init(object, device, &normalized_desc); + wined3d_mutex_unlock(); + if (FAILED(hr)) { WARN("Failed to initialize sampler state, hr %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object);