d2d1: Check for NULL pointer when releasing previous render target view.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2017-01-25 00:47:38 +03:00 committed by Alexandre Julliard
parent 6ab887c057
commit 621675e8f8
2 changed files with 8 additions and 1 deletions

View File

@ -2375,7 +2375,8 @@ HRESULT d2d_d3d_render_target_create_rtv(ID2D1RenderTarget *iface, IDXGISurface1
render_target->pixel_size.width = surface_desc.Width;
render_target->pixel_size.height = surface_desc.Height;
ID3D10RenderTargetView_Release(render_target->view);
if (render_target->view)
ID3D10RenderTargetView_Release(render_target->view);
render_target->view = view;
return S_OK;

View File

@ -3129,6 +3129,7 @@ static void test_hwnd_target(void)
ID2D1HwndRenderTarget *rt;
ID2D1Factory *factory;
ID3D10Device1 *device;
D2D1_SIZE_U size;
HRESULT hr;
if (!(device = create_device()))
@ -3166,6 +3167,11 @@ static void test_hwnd_target(void)
hr = ID2D1Factory_CreateHwndRenderTarget(factory, &desc, &hwnd_rt_desc, &rt);
ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
size.width = 128;
size.height = 64;
hr = ID2D1HwndRenderTarget_Resize(rt, &size);
ok(SUCCEEDED(hr), "Failed to resize render target, hr %#x.\n", hr);
ID2D1HwndRenderTarget_Release(rt);
DestroyWindow(hwnd_rt_desc.hwnd);