d3drm: Check for NULL pointer in d3drm_viewport2_GetDirect3DViewport().

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jeff Smith 2019-07-08 10:19:44 -05:00 committed by Alexandre Julliard
parent 76a7fe59eb
commit d2d64ced53
2 changed files with 7 additions and 0 deletions

View File

@ -2155,6 +2155,8 @@ static void test_Viewport(void)
ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
hr = IDirect3DRMViewport_GetDevice(viewport, NULL); hr = IDirect3DRMViewport_GetDevice(viewport, NULL);
ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, NULL);
ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
IDirect3DRMViewport_Release(viewport); IDirect3DRMViewport_Release(viewport);
ref4 = get_refcount((IUnknown *)d3drm1); ref4 = get_refcount((IUnknown *)d3drm1);
@ -2245,6 +2247,8 @@ static void test_Viewport(void)
ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
hr = IDirect3DRMViewport2_GetDevice(viewport2, NULL); hr = IDirect3DRMViewport2_GetDevice(viewport2, NULL);
ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, NULL);
ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
IDirect3DRMViewport2_Release(viewport2); IDirect3DRMViewport2_Release(viewport2);
ref4 = get_refcount((IUnknown *)d3drm1); ref4 = get_refcount((IUnknown *)d3drm1);

View File

@ -896,6 +896,9 @@ static HRESULT WINAPI d3drm_viewport2_GetDirect3DViewport(IDirect3DRMViewport2 *
TRACE("iface %p, viewport %p.\n", iface, viewport); TRACE("iface %p, viewport %p.\n", iface, viewport);
if (!viewport)
return D3DRMERR_BADVALUE;
if (!viewport_object->d3d_viewport) if (!viewport_object->d3d_viewport)
return D3DRMERR_BADOBJECT; return D3DRMERR_BADOBJECT;