From 621675e8f889c0003e9802ad2000d3332bfe132d Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 25 Jan 2017 00:47:38 +0300 Subject: [PATCH] d2d1: Check for NULL pointer when releasing previous render target view. Signed-off-by: Nikolay Sivov Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d2d1/render_target.c | 3 ++- dlls/d2d1/tests/d2d1.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c index 0a70897c225..187e1e0f943 100644 --- a/dlls/d2d1/render_target.c +++ b/dlls/d2d1/render_target.c @@ -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; diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index cde8579f0bf..5df5b6e3f00 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -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);