[PATCH] Checked all the states of variables in test to ensure that they are not NULL
Chris Ahrendt
celticht32 at aol.com
Tue Oct 7 20:02:36 CDT 2008
---
dlls/ddraw/tests/dsurface.c | 170 +++++++++++++++++++++---------------------
1 files changed, 85 insertions(+), 85 deletions(-)
diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
index fc7bb88..23950a3 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -90,7 +90,7 @@ static void MipMapCreationTest(void)
U2(ddsd).dwMipMapCount);
/* Destroy the surface. */
- IDirectDrawSurface_Release(lpDDSMipMapTest);
+ if (lpDDSMipMapTest) IDirectDrawSurface_Release(lpDDSMipMapTest);
/* Second mipmap creation test: create a surface without a mipmap
@@ -119,7 +119,7 @@ static void MipMapCreationTest(void)
U2(ddsd).dwMipMapCount);
/* Destroy the surface. */
- IDirectDrawSurface_Release(lpDDSMipMapTest);
+ if (lpDDSMipMapTest) IDirectDrawSurface_Release(lpDDSMipMapTest);
/* Third mipmap creation test: create a surface with DDSCAPS_MIPMAP,
@@ -152,7 +152,7 @@ static void MipMapCreationTest(void)
U2(ddsd).dwMipMapCount);
/* Destroy the surface. */
- IDirectDrawSurface_Release(lpDDSMipMapTest);
+ if (lpDDSMipMapTest) IDirectDrawSurface_Release(lpDDSMipMapTest);
/* Fourth mipmap creation test: same as above with a different texture
@@ -183,7 +183,7 @@ static void MipMapCreationTest(void)
U2(ddsd).dwMipMapCount);
/* Destroy the surface. */
- IDirectDrawSurface_Release(lpDDSMipMapTest);
+ if (lpDDSMipMapTest) IDirectDrawSurface_Release(lpDDSMipMapTest);
/* Fifth mipmap creation test: try to create a surface with
@@ -201,7 +201,7 @@ static void MipMapCreationTest(void)
/* Destroy the surface. */
if( rc == DD_OK )
- IDirectDrawSurface_Release(lpDDSMipMapTest);
+ if (lpDDSMipMapTest) IDirectDrawSurface_Release(lpDDSMipMapTest);
}
@@ -324,8 +324,8 @@ static void SrcColorKey32BlitTest(void)
ok(ddsd.ddckCKSrcBlt.dwColorSpaceLowValue == 0x00FF00 && ddsd.ddckCKSrcBlt.dwColorSpaceHighValue == 0x00FF00,
"GetSurfaceDesc does not return the colorkey set with SetColorKey\n");
- IDirectDrawSurface_Release(lpSrc);
- IDirectDrawSurface_Release(lpDst);
+ if (lpSrc) IDirectDrawSurface_Release(lpSrc);
+ if (lpDst) IDirectDrawSurface_Release(lpDst);
/* start with a new set of surfaces to test the color keying parameters to blit */
memset(&ddsd, 0, sizeof(ddsd));
@@ -374,7 +374,7 @@ static void SrcColorKey32BlitTest(void)
if(FAILED(rc))
{
skip("Failed to create surface\n");
- IDirectDrawSurface_Release(lpDst);
+ if(lpDst) IDirectDrawSurface_Release(lpDst);
return;
}
@@ -657,8 +657,8 @@ static void SrcColorKey32BlitTest(void)
rc = IDirectDrawSurface_Blt(lpDst, NULL, lpSrc, NULL, DDBLT_KEYSRCOVERRIDE, &fx);
ok(rc == DD_OK, "IDirectDrawSurface_Blt returned %08x\n", rc);
- IDirectDrawSurface_Release(lpSrc);
- IDirectDrawSurface_Release(lpDst);
+ if (lpSrc) IDirectDrawSurface_Release(lpSrc);
+ if (lpDst) IDirectDrawSurface_Release(lpDst);
}
static void QueryInterface(void)
@@ -685,7 +685,7 @@ static void QueryInterface(void)
ret = IDirectDrawSurface_QueryInterface(dsurface, 0, &object);
ok(ret == DDERR_INVALIDPARAMS, "IDirectDrawSurface::QueryInterface returned %x\n", ret);
- IDirectDrawSurface_Release(dsurface);
+ if (dsurface) IDirectDrawSurface_Release(dsurface);
}
/* The following tests test which interface is returned by IDirectDrawSurfaceX::GetDDInterface.
@@ -756,11 +756,11 @@ static void GetDDInterface_1(void)
ret = IDirectDrawSurface2_GetDDInterface(dsurface2, NULL);
ok(ret == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
- IDirectDraw_Release(dd2);
- IDirectDraw_Release(dd4);
- IDirectDraw_Release(dd7);
- IDirectDrawSurface2_Release(dsurface2);
- IDirectDrawSurface_Release(dsurface);
+ if (dd2) IDirectDraw_Release(dd2);
+ if (dd4) IDirectDraw_Release(dd4);
+ if (dd7) IDirectDraw_Release(dd7);
+ if (dsurface2) IDirectDrawSurface2_Release(dsurface2);
+ if (dsurface) IDirectDrawSurface_Release(dsurface);
}
static void GetDDInterface_2(void)
@@ -815,13 +815,13 @@ static void GetDDInterface_2(void)
ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
ok(dd == dd2, "Returned interface pointer is not equal to the creation interface\n");
- IUnknown_Release((IUnknown *) dd);
+ if (dd) IUnknown_Release((IUnknown *) dd);
- IDirectDraw_Release(dd2);
- IDirectDraw_Release(dd4);
- IDirectDraw_Release(dd7);
- IDirectDrawSurface2_Release(dsurface2);
- IDirectDrawSurface_Release(dsurface);
+ if (dd2) IDirectDraw_Release(dd2);
+ if (dd4) IDirectDraw_Release(dd4);
+ if (dd7) IDirectDraw_Release(dd7);
+ if (dsurface2) IDirectDrawSurface2_Release(dsurface2);
+ if (dsurface) IDirectDrawSurface_Release(dsurface);
}
static void GetDDInterface_4(void)
@@ -875,7 +875,7 @@ static void GetDDInterface_4(void)
ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
ok(dd == dd4, "Returned interface pointer is not equal to the creation interface\n");
- IUnknown_Release((IUnknown *) dd);
+ if (dd) IUnknown_Release((IUnknown *) dd);
/* Now test what happens if we QI the surface for some other version - It should still return the creation interface */
ret = IDirectDrawSurface2_GetDDInterface(dsurface2, &dd);
@@ -888,11 +888,11 @@ static void GetDDInterface_4(void)
ok(dd == dd4, "Returned interface pointer is not equal to the creation interface\n");
IUnknown_Release((IUnknown *) dd);
- IDirectDraw_Release(dd2);
- IDirectDraw_Release(dd4);
- IDirectDraw_Release(dd7);
- IDirectDrawSurface4_Release(dsurface4);
- IDirectDrawSurface2_Release(dsurface2);
+ if (dd2) IDirectDraw_Release(dd2);
+ if (dd4) IDirectDraw_Release(dd4);
+ if (dd7) IDirectDraw_Release(dd7);
+ if (dsurface4) IDirectDrawSurface4_Release(dsurface4);
+ if (dsurface2) IDirectDrawSurface2_Release(dsurface2);
}
static void GetDDInterface_7(void)
@@ -946,7 +946,7 @@ static void GetDDInterface_7(void)
ok(getref((IUnknown *) dd7) == ref7 + 1, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
ok(dd == dd7, "Returned interface pointer is not equal to the creation interface\n");
- IUnknown_Release((IUnknown *) dd);
+ if (dd) IUnknown_Release((IUnknown *) dd);
/* Now test what happens if we QI the surface for some other version - It should still return the creation interface */
ret = IDirectDrawSurface4_GetDDInterface(dsurface4, &dd);
@@ -959,11 +959,11 @@ static void GetDDInterface_7(void)
ok(dd == dd7, "Returned interface pointer is not equal to the creation interface\n");
IUnknown_Release((IUnknown *) dd);
- IDirectDraw_Release(dd2);
- IDirectDraw_Release(dd4);
- IDirectDraw_Release(dd7);
- IDirectDrawSurface4_Release(dsurface4);
- IDirectDrawSurface7_Release(dsurface7);
+ if (dd2) IDirectDraw_Release(dd2);
+ if (dd4) IDirectDraw_Release(dd4);
+ if (dd7) IDirectDraw_Release(dd7);
+ if (dsurface4) IDirectDrawSurface4_Release(dsurface4);
+ if (dsurface7) IDirectDrawSurface7_Release(dsurface7);
}
#define MAXEXPECTED 8 /* Can match up to 8 expected surfaces */
@@ -985,7 +985,7 @@ static HRESULT WINAPI enumCB(IDirectDrawSurface *surf, DDSURFACEDESC *desc, void
ok(found, "Unexpected surface %p enumerated\n", surf);
((struct enumstruct *)ctx)->count++;
- IDirectDrawSurface_Release(surf);
+ if (surf) IDirectDrawSurface_Release(surf);
return DDENUMRET_OK;
}
@@ -1020,16 +1020,16 @@ static void EnumTest(void)
ok(rc == DD_OK, "IDirectDraw_EnumSurfaces returned %08x\n", rc);
ok(ctx.count == 3, "%d surfaces enumerated, expected 3\n", ctx.count);
- IDirectDrawSurface_Release(ctx.expected[2]);
- IDirectDrawSurface_Release(ctx.expected[1]);
- IDirectDrawSurface_Release(surface);
+ if (ctx.expected[2]) IDirectDrawSurface_Release(ctx.expected[2]);
+ if (ctx.expected[1]) IDirectDrawSurface_Release(ctx.expected[1]);
+ if (surface) IDirectDrawSurface_Release(surface);
}
HRESULT WINAPI SurfaceCounter(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *desc, void *context)
{
UINT *num = context;
(*num)++;
- IDirectDrawSurface_Release(surface);
+ if (surface) IDirectDrawSurface_Release(surface);
return DDENUMRET_OK;
}
@@ -1073,7 +1073,7 @@ static void AttachmentTest7(void)
/* LEVEL 2 */
hr = IDirectDrawSurface7_GetAttachedSurface(surface2, &caps, &surface3);
ok(hr == DD_OK, "GetAttachedSurface returned %08x\n", hr);
- IDirectDrawSurface7_Release(surface2);
+ if (surface2) IDirectDrawSurface7_Release(surface2);
num = 0;
IDirectDrawSurface7_EnumAttachedSurfaces(surface3, &num, SurfaceCounter);
ok(num == 0, "Second mip level has %d surfaces attached, expected 1\n", num);
@@ -1102,7 +1102,7 @@ static void AttachmentTest7(void)
hr = IDirectDrawSurface7_AddAttachedSurface(surface2, surface3);
ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a 32x32 texture mip level to a 16x16 surface returned %08x\n", hr);
- IDirectDrawSurface7_Release(surface2);
+ if (surface2) IDirectDrawSurface7_Release(surface2);
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
@@ -1122,9 +1122,9 @@ static void AttachmentTest7(void)
hr = IDirectDrawSurface7_AddAttachedSurface(surface2, surface3);
ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a 32x32 texture mip level to a 16x16 offscreen plain surface returned %08x\n", hr);
- IDirectDrawSurface7_Release(surface3);
- IDirectDrawSurface7_Release(surface2);
- IDirectDrawSurface7_Release(surface1);
+ if (surface3) IDirectDrawSurface7_Release(surface3);
+ if (surface2) IDirectDrawSurface7_Release(surface2);
+ if (surface1) IDirectDrawSurface7_Release(surface1);
hr = IDirectDraw7_SetCooperativeLevel(dd7, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
@@ -1140,7 +1140,7 @@ static void AttachmentTest7(void)
num = 0;
IDirectDrawSurface7_EnumAttachedSurfaces(surface1, &num, SurfaceCounter);
ok(num == 1, "Primary surface has %d surfaces attached, expected 1\n", num);
- IDirectDrawSurface7_Release(surface1);
+ if (surface1) IDirectDrawSurface7_Release(surface1);
/* Those are some invalid descriptions, no need to test attachments with them */
memset(&ddsd, 0, sizeof(ddsd));
@@ -1203,14 +1203,14 @@ static void AttachmentTest7(void)
hr = IDirectDrawSurface7_AddAttachedSurface(surface4, surface1);
ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a front buffer to an offscreen plain surface of different size returned %08x\n", hr);
- IDirectDrawSurface7_Release(surface4);
- IDirectDrawSurface7_Release(surface3);
- IDirectDrawSurface7_Release(surface2);
- IDirectDrawSurface7_Release(surface1);
+ if (surface4) IDirectDrawSurface7_Release(surface4);
+ if (surface3) IDirectDrawSurface7_Release(surface3);
+ if (surface2) IDirectDrawSurface7_Release(surface2);
+ if (surface1) IDirectDrawSurface7_Release(surface1);
hr =IDirectDraw7_SetCooperativeLevel(dd7, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
- IDirectDraw7_Release(dd7);
+ if (dd7) IDirectDraw7_Release(dd7);
}
static void AttachmentTest(void)
@@ -1260,7 +1260,7 @@ static void AttachmentTest(void)
hr = IDirectDrawSurface7_AddAttachedSurface(surface4, surface2);
ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a 64x64 texture sublevel to a 16x16 texture returned %08x\n", hr);
- IDirectDrawSurface7_Release(surface4);
+ if (surface4) IDirectDrawSurface7_Release(surface4);
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
@@ -1313,10 +1313,10 @@ static void AttachmentTest(void)
ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a 64x64 texture sublevel to a 16x16 offscreen plain surface returned %08x\n", hr);
if(SUCCEEDED(hr)) IDirectDrawSurface7_DeleteAttachedSurface(surface4, 0, surface2);
- IDirectDrawSurface7_Release(surface4);
- IDirectDrawSurface7_Release(surface3);
- IDirectDrawSurface7_Release(surface2);
- IDirectDrawSurface7_Release(surface1);
+ if (surface4) IDirectDrawSurface7_Release(surface4);
+ if (surface3) IDirectDrawSurface7_Release(surface3);
+ if (surface2) IDirectDrawSurface7_Release(surface2);
+ if (surface1) IDirectDrawSurface7_Release(surface1);
hr = IDirectDraw_SetCooperativeLevel(lpDD, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
@@ -1335,7 +1335,7 @@ static void AttachmentTest(void)
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER;
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface1, NULL);
ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
- IDirectDrawSurface_Release(surface1);
+ if (surface1) IDirectDrawSurface_Release(surface1);
/* Try a single primary and two offscreen plain surfaces */
memset(&ddsd, 0, sizeof(ddsd));
@@ -1400,10 +1400,10 @@ static void AttachmentTest(void)
hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a front buffer to an offscreen plain surface of different size returned %08x\n", hr);
- IDirectDrawSurface_Release(surface4);
- IDirectDrawSurface_Release(surface3);
- IDirectDrawSurface_Release(surface2);
- IDirectDrawSurface_Release(surface1);
+ if (surface4) IDirectDrawSurface_Release(surface4);
+ if (surface3) IDirectDrawSurface_Release(surface3);
+ if (surface2) IDirectDrawSurface_Release(surface2);
+ if (surface1) IDirectDrawSurface_Release(surface1);
hr =IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
@@ -1487,7 +1487,7 @@ HRESULT WINAPI CubeTestLvl1Enum(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *de
(*num)++;
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
return DDENUMRET_OK;
}
@@ -1539,7 +1539,7 @@ static void CubeMapTest(void)
&num,
CubeTestLvl1Enum);
ok(num == 6, "Surface has %d attachments\n", num);
- IDirectDrawSurface7_Release(cubemap);
+ if (cubemap) IDirectDrawSurface7_Release(cubemap);
/* What happens if I do not specify any faces? */
memset(&ddsd, 0, sizeof(ddsd));
@@ -1723,7 +1723,7 @@ static void test_lockrect_invalid(void)
hr = IDirectDrawSurface_Unlock(surface, NULL);
ok(hr == DD_OK, "Unlock returned (0x%08x)\n", hr);
- IDirectDrawSurface_Release(surface);
+ if (surface) IDirectDrawSurface_Release(surface);
}
}
@@ -1770,7 +1770,7 @@ static void CompressedTest(void)
"Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
ok(U1(ddsd2).dwLinearSize == 8192, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
ok(ddsd2.ddsCaps.dwCaps2 == 0, "Caps2: %08x\n", ddsd2.ddsCaps.dwCaps2);
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','3');
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
@@ -1793,7 +1793,7 @@ static void CompressedTest(void)
ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
"Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','5');
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
@@ -1871,7 +1871,7 @@ static void CompressedTest(void)
hr = IDirectDrawSurface7_Unlock(surface, &r2);
ok(hr == DD_OK, "Unlock returned %08x\n", hr);
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
/* Try this with video memory. A kind of surprise. It still has the LINEARSIZE flag set,
* but seems to have a pitch instead.
@@ -1900,7 +1900,7 @@ static void CompressedTest(void)
"Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
/* ATI drivers report a broken linear size, thus no need to clone the exact behaviour. nvidia reports the correct size */
ok(ddsd2.ddsCaps.dwCaps2 == 0, "Caps2: %08x\n", ddsd2.ddsCaps.dwCaps2);
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','3');
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
@@ -1919,7 +1919,7 @@ static void CompressedTest(void)
ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
"Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
/* ATI drivers report a broken linear size, thus no need to clone the exact behaviour. nvidia reports the correct size */
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','5');
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
@@ -1994,7 +1994,7 @@ static void CompressedTest(void)
hr = IDirectDrawSurface7_Unlock(surface, &r2);
ok(hr == DD_OK, "Unlock returned %08x\n", hr);
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
}
else
{
@@ -2028,7 +2028,7 @@ static void CompressedTest(void)
"Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
ok(U1(ddsd2).dwLinearSize == 8192, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
ok(ddsd2.ddsCaps.dwCaps2 == DDSCAPS2_TEXTUREMANAGE, "Caps2: %08x\n", ddsd2.ddsCaps.dwCaps2);
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','3');
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
@@ -2047,7 +2047,7 @@ static void CompressedTest(void)
ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
"Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','5');
hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
@@ -2122,14 +2122,14 @@ static void CompressedTest(void)
hr = IDirectDrawSurface7_Unlock(surface, &r2);
ok(hr == DD_OK, "Unlock returned %08x\n", hr);
- IDirectDrawSurface7_Release(surface);
+ if (surface) IDirectDrawSurface7_Release(surface);
}
else
{
skip("Hardware DXTN textures not supported\n");
}
- IDirectDraw7_Release(dd7);
+ if (dd7) IDirectDraw7_Release(dd7);
}
static void SizeTest(void)
@@ -2249,7 +2249,7 @@ static void PrivateDataTest(void)
}
hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **) &surface7);
ok(hr == DD_OK, "IDirectDrawSurface_QueryInterface failed with %08x\n", hr);
- if(!surface)
+ if(surface)
{
IDirectDrawSurface_Release(surface);
return;
@@ -2288,8 +2288,8 @@ static void PrivateDataTest(void)
ok(ptr == (IUnknown *) lpDD, "Returned interface pointer is %p, expected %p\n", ptr, lpDD);
ok(ref2 == ref + 1, "Object reference is %d, expected %d. ptr at %p, orig at %p\n", ref2, ref + 1, ptr, lpDD);
- IDirectDrawSurface_Release(surface);
- IDirectDrawSurface7_Release(surface7);
+ if (surface) IDirectDrawSurface_Release(surface);
+ if (surface7) IDirectDrawSurface7_Release(surface7);
/* Destroying the surface frees the held reference */
ref2 = getref((IUnknown *) lpDD);
@@ -2397,8 +2397,8 @@ static void BltParamTest(void)
hr = IDirectDrawSurface_Blt(surface1, NULL, surface2, &invalid4, 0, NULL);
ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08x\n", hr);
- IDirectDrawSurface_Release(surface1);
- IDirectDrawSurface_Release(surface2);
+ if (surface1) IDirectDrawSurface_Release(surface1);
+ if (surface2) IDirectDrawSurface_Release(surface2);
}
static void PaletteTest(void)
@@ -2458,7 +2458,7 @@ static void PaletteTest(void)
"Palette entry 255 should have been set to (255,255,255) but it contains (%d,%d,%d)\n",
palEntries[255].peRed, palEntries[255].peGreen, palEntries[255].peBlue);
}
- IDirectDrawPalette_Release(palette);
+ if (palette) IDirectDrawPalette_Release(palette);
/* Create a 8bit palette with DDPCAPS_ALLOW256 set */
hr = IDirectDraw_CreatePalette(lpDD, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
@@ -2498,7 +2498,7 @@ static void PaletteTest(void)
hr = IDirectDrawSurface_SetPalette(lpSurf, palette);
ok(hr == DDERR_INVALIDPIXELFORMAT, "CreateSurface returned: %x\n",hr);
- IDirectDrawPalette_Release(palette);
+ if (palette) IDirectDrawPalette_Release(palette);
palette = NULL;
hr = IDirectDrawSurface_GetPalette(lpSurf, &palette);
@@ -2612,8 +2612,8 @@ static void StructSizeTest(void)
ok(hr == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_Lock with desc size sizeof(DDSURFACEDESC2) + 1returned %08x\n", hr);
if(SUCCEEDED(hr)) IDirectDrawSurface7_Unlock(surface7, NULL);
- IDirectDrawSurface7_Release(surface7);
- IDirectDrawSurface_Release(surface1);
+ if (surface7) IDirectDrawSurface7_Release(surface7);
+ if (surface1) IDirectDrawSurface_Release(surface1);
}
static void SurfaceCapsTest(void)
@@ -2694,7 +2694,7 @@ static void SurfaceCapsTest(void)
"GetSurfaceDesc returned caps %x, expected %x\n", desc.ddsCaps.dwCaps,
expected_caps[i]);
- IDirectDrawSurface_Release(surface1);
+ if (surface1) IDirectDrawSurface_Release(surface1);
}
}
@@ -2740,11 +2740,11 @@ static void SurfaceCapsTest(void)
"GetSurfaceDesc returned caps %x, expected %x\n", desc2.ddsCaps.dwCaps,
expected_caps[i]);
- IDirectDrawSurface7_Release(surface7);
+ if (surface7) IDirectDrawSurface7_Release(surface7);
}
}
- IDirectDraw7_Release(dd7);
+ if (dd7) IDirectDraw7_Release(dd7);
}
}
--
1.5.5.1
--------------040301000604010701090808--
More information about the wine-patches
mailing list