ddraw/tests: Fix possible memory leaks.
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e89c85118b
commit
8915500868
|
@ -109,7 +109,11 @@ static BOOL CreateDirect3D(void)
|
||||||
ok(rc==DD_OK, "SetCooperativeLevel returned: %x\n", rc);
|
ok(rc==DD_OK, "SetCooperativeLevel returned: %x\n", rc);
|
||||||
|
|
||||||
rc = IDirectDraw7_QueryInterface(lpDD, &IID_IDirect3D7, (void**) &lpD3D);
|
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);
|
ok(rc==DD_OK, "QueryInterface returned: %x\n", rc);
|
||||||
|
|
||||||
memset(&ddsd, 0, sizeof(ddsd));
|
memset(&ddsd, 0, sizeof(ddsd));
|
||||||
|
@ -120,7 +124,11 @@ static BOOL CreateDirect3D(void)
|
||||||
ddsd.dwHeight = 256;
|
ddsd.dwHeight = 256;
|
||||||
rc = IDirectDraw7_CreateSurface(lpDD, &ddsd, &lpDDS, NULL);
|
rc = IDirectDraw7_CreateSurface(lpDD, &ddsd, &lpDDS, NULL);
|
||||||
if (FAILED(rc))
|
if (FAILED(rc))
|
||||||
|
{
|
||||||
|
IDirect3D7_Release(lpD3D);
|
||||||
|
IDirectDraw7_Release(lpDD);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
num = 0;
|
num = 0;
|
||||||
IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST, NULL, &num, SurfaceCounter);
|
IDirectDraw7_EnumSurfaces(lpDD, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST, NULL, &num, SurfaceCounter);
|
||||||
|
@ -144,7 +152,13 @@ static BOOL CreateDirect3D(void)
|
||||||
rc = IDirectDrawSurface_AddAttachedSurface(lpDDS, lpDDSdepth);
|
rc = IDirectDrawSurface_AddAttachedSurface(lpDDS, lpDDSdepth);
|
||||||
ok(rc == DD_OK, "IDirectDrawSurface_AddAttachedSurface returned %x\n", rc);
|
ok(rc == DD_OK, "IDirectDrawSurface_AddAttachedSurface returned %x\n", rc);
|
||||||
if (FAILED(rc))
|
if (FAILED(rc))
|
||||||
|
{
|
||||||
|
IDirectDrawSurface7_Release(lpDDSdepth);
|
||||||
|
IDirectDrawSurface7_Release(lpDDS);
|
||||||
|
IDirect3D7_Release(lpD3D);
|
||||||
|
IDirectDraw7_Release(lpDD);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = IDirect3D7_CreateDevice(lpD3D, &IID_IDirect3DTnLHalDevice, lpDDS,
|
rc = IDirect3D7_CreateDevice(lpD3D, &IID_IDirect3DTnLHalDevice, lpDDS,
|
||||||
|
@ -160,6 +174,11 @@ static BOOL CreateDirect3D(void)
|
||||||
&lpD3DDevice);
|
&lpD3DDevice);
|
||||||
if (!lpD3DDevice) {
|
if (!lpD3DDevice) {
|
||||||
trace("IDirect3D7::CreateDevice() for a RGB device failed with an error %x, giving up\n", rc);
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,6 +165,9 @@ static void GetDDInterface_2(void)
|
||||||
if(ret != DD_OK)
|
if(ret != DD_OK)
|
||||||
{
|
{
|
||||||
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
|
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
|
||||||
|
IDirectDraw2_Release(dd2);
|
||||||
|
IDirectDraw4_Release(dd4);
|
||||||
|
IDirectDraw7_Release(dd7);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ret = IDirectDrawSurface_QueryInterface(dsurface, &IID_IDirectDrawSurface2, (void **) &dsurface2);
|
ret = IDirectDrawSurface_QueryInterface(dsurface, &IID_IDirectDrawSurface2, (void **) &dsurface2);
|
||||||
|
@ -226,6 +229,9 @@ static void GetDDInterface_4(void)
|
||||||
if(ret != DD_OK)
|
if(ret != DD_OK)
|
||||||
{
|
{
|
||||||
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
|
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
|
||||||
|
IDirectDraw2_Release(dd2);
|
||||||
|
IDirectDraw4_Release(dd4);
|
||||||
|
IDirectDraw7_Release(dd7);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ret = IDirectDrawSurface4_QueryInterface(dsurface4, &IID_IDirectDrawSurface2, (void **) &dsurface2);
|
ret = IDirectDrawSurface4_QueryInterface(dsurface4, &IID_IDirectDrawSurface2, (void **) &dsurface2);
|
||||||
|
@ -297,6 +303,9 @@ static void GetDDInterface_7(void)
|
||||||
if(ret != DD_OK)
|
if(ret != DD_OK)
|
||||||
{
|
{
|
||||||
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
|
ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
|
||||||
|
IDirectDraw2_Release(dd2);
|
||||||
|
IDirectDraw4_Release(dd4);
|
||||||
|
IDirectDraw7_Release(dd7);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ret = IDirectDrawSurface7_QueryInterface(dsurface7, &IID_IDirectDrawSurface4, (void **) &dsurface4);
|
ret = IDirectDrawSurface7_QueryInterface(dsurface7, &IID_IDirectDrawSurface4, (void **) &dsurface4);
|
||||||
|
|
|
@ -97,6 +97,9 @@ static void test_ddraw_objects(void)
|
||||||
if (!surface)
|
if (!surface)
|
||||||
{
|
{
|
||||||
win_skip("Could not create surface : %08x\n", hr);
|
win_skip("Could not create surface : %08x\n", hr);
|
||||||
|
IDirectDraw_Release(DDraw1);
|
||||||
|
IDirectDraw2_Release(DDraw2);
|
||||||
|
IDirectDraw4_Release(DDraw4);
|
||||||
IDirectDraw7_Release(DDraw7);
|
IDirectDraw7_Release(DDraw7);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue