Commit 89155008 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

ddraw/tests: Fix possible memory leaks.

parent e89c8511
......@@ -109,7 +109,11 @@ static BOOL CreateDirect3D(void)
ok(rc==DD_OK, "SetCooperativeLevel returned: %x\n", rc);
rc = IDirectDraw7_QueryInterface(lpDD, &IID_IDirect3D7, (void**) &lpD3D);
if (rc == E_NOINTERFACE) return FALSE;
if (rc == E_NOINTERFACE)
{
IDirectDraw7_Release(lpDD);
return FALSE;
}
ok(rc==DD_OK, "QueryInterface returned: %x\n", rc);
memset(&ddsd, 0, sizeof(ddsd));
......@@ -120,7 +124,11 @@ static BOOL CreateDirect3D(void)
ddsd.dwHeight = 256;
rc = IDirectDraw7_CreateSurface(lpDD, &ddsd, &lpDDS, NULL);
if (FAILED(rc))
{
IDirect3D7_Release(lpD3D);
IDirectDraw7_Release(lpDD);
return FALSE;
}
num = 0;
IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST, NULL, &num, SurfaceCounter);
......@@ -144,7 +152,13 @@ static BOOL CreateDirect3D(void)
rc = IDirectDrawSurface_AddAttachedSurface(lpDDS, lpDDSdepth);
ok(rc == DD_OK, "IDirectDrawSurface_AddAttachedSurface returned %x\n", rc);
if (FAILED(rc))
{
IDirectDrawSurface7_Release(lpDDSdepth);
IDirectDrawSurface7_Release(lpDDS);
IDirect3D7_Release(lpD3D);
IDirectDraw7_Release(lpDD);
return FALSE;
}
}
rc = IDirect3D7_CreateDevice(lpD3D, &IID_IDirect3DTnLHalDevice, lpDDS,
......@@ -160,6 +174,11 @@ static BOOL CreateDirect3D(void)
&lpD3DDevice);
if (!lpD3DDevice) {
trace("IDirect3D7::CreateDevice() for a RGB device failed with an error %x, giving up\n", rc);
if (lpDDSdepth)
IDirectDrawSurface7_Release(lpDDSdepth);
IDirectDrawSurface7_Release(lpDDS);
IDirect3D7_Release(lpD3D);
IDirectDraw7_Release(lpDD);
return FALSE;
}
}
......
......@@ -165,6 +165,9 @@ static void GetDDInterface_2(void)
if(ret != DD_OK)
{
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
IDirectDraw2_Release(dd2);
IDirectDraw4_Release(dd4);
IDirectDraw7_Release(dd7);
return;
}
ret = IDirectDrawSurface_QueryInterface(dsurface, &IID_IDirectDrawSurface2, (void **) &dsurface2);
......@@ -226,6 +229,9 @@ static void GetDDInterface_4(void)
if(ret != DD_OK)
{
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
IDirectDraw2_Release(dd2);
IDirectDraw4_Release(dd4);
IDirectDraw7_Release(dd7);
return;
}
ret = IDirectDrawSurface4_QueryInterface(dsurface4, &IID_IDirectDrawSurface2, (void **) &dsurface2);
......@@ -297,6 +303,9 @@ static void GetDDInterface_7(void)
if(ret != DD_OK)
{
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
IDirectDraw2_Release(dd2);
IDirectDraw4_Release(dd4);
IDirectDraw7_Release(dd7);
return;
}
ret = IDirectDrawSurface7_QueryInterface(dsurface7, &IID_IDirectDrawSurface4, (void **) &dsurface4);
......
......@@ -97,6 +97,9 @@ static void test_ddraw_objects(void)
if (!surface)
{
win_skip("Could not create surface : %08x\n", hr);
IDirectDraw_Release(DDraw1);
IDirectDraw2_Release(DDraw2);
IDirectDraw4_Release(DDraw4);
IDirectDraw7_Release(DDraw7);
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment