d3d11: Avoid potential double free in d3d11_device_CreateSamplerState().
The parent is owned by the wined3d_sampler object and it is destroyed in the wined3d_object_destroyed() callback. 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>
This commit is contained in:
parent
478cc5b2a3
commit
fb807220c4
|
@ -1257,23 +1257,25 @@ HRESULT d3d_sampler_state_init(struct d3d_sampler_state *state, struct d3d_devic
|
|||
wined3d_desc.comparison_func = wined3d_cmp_func_from_d3d11(desc->ComparisonFunc);
|
||||
wined3d_desc.srgb_decode = TRUE;
|
||||
|
||||
if (wine_rb_put(&device->sampler_states, desc, &state->entry) == -1)
|
||||
{
|
||||
ERR("Failed to insert sampler state entry.\n");
|
||||
wined3d_private_store_cleanup(&state->private_store);
|
||||
wined3d_mutex_unlock();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
/* We cannot fail after creating a wined3d_sampler object. It would lead to
|
||||
* double free. */
|
||||
if (FAILED(hr = wined3d_sampler_create(device->wined3d_device, &wined3d_desc,
|
||||
state, &d3d_sampler_wined3d_parent_ops, &state->wined3d_sampler)))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if (wine_rb_put(&device->sampler_states, desc, &state->entry) == -1)
|
||||
{
|
||||
ERR("Failed to insert sampler state entry.\n");
|
||||
wined3d_sampler_decref(state->wined3d_sampler);
|
||||
wined3d_private_store_cleanup(&state->private_store);
|
||||
wined3d_mutex_unlock();
|
||||
return E_FAIL;
|
||||
}
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
state->device = &device->ID3D11Device_iface;
|
||||
|
|
Loading…
Reference in New Issue