From 2caa797e76273852f3aa52491261e24a6d1229a7 Mon Sep 17 00:00:00 2001 From: Alexander Dorofeyev Date: Thu, 3 Apr 2008 00:11:43 +0300 Subject: [PATCH] ddraw: Set surface to NULL on failure in GetAttachedSurface. --- dlls/ddraw/surface.c | 2 ++ dlls/ddraw/surface_thunks.c | 5 ++--- dlls/ddraw/tests/dsurface.c | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index c48e07ee2a7..da152de85f9 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -540,6 +540,8 @@ IDirectDrawSurfaceImpl_GetAttachedSurface(IDirectDrawSurface7 *iface, TRACE("(%p) Didn't find a valid surface\n", This); LeaveCriticalSection(&ddraw_cs); + + *Surface = NULL; return DDERR_NOTFOUND; } diff --git a/dlls/ddraw/surface_thunks.c b/dlls/ddraw/surface_thunks.c index ef6d48f5bde..a0786bb78b6 100644 --- a/dlls/ddraw/surface_thunks.c +++ b/dlls/ddraw/surface_thunks.c @@ -228,9 +228,8 @@ IDirectDrawSurface3Impl_GetAttachedSurface(LPDIRECTDRAWSURFACE3 This, hr = IDirectDrawSurface7_GetAttachedSurface(CONVERT(This), &caps, &pAttached7); - if (FAILED(hr)) return hr; - - *ppAttached = CONVERT_REV(pAttached7); + if (FAILED(hr)) *ppAttached = NULL; + else *ppAttached = CONVERT_REV(pAttached7); return hr; } diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c index 7ff1fe75d00..1e35e372acd 100644 --- a/dlls/ddraw/tests/dsurface.c +++ b/dlls/ddraw/tests/dsurface.c @@ -1012,6 +1012,7 @@ static void EnumTest(void) ok(rc == DD_OK, "GetAttachedSurface returned %08x\n", rc); rc = IDirectDrawSurface_GetAttachedSurface(ctx.expected[2], &ddsd.ddsCaps, &ctx.expected[3]); ok(rc == DDERR_NOTFOUND, "GetAttachedSurface returned %08x\n", rc); + ok(!ctx.expected[3], "expected NULL pointer\n"); ctx.count = 0; rc = IDirectDraw_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, &ddsd, (void *) &ctx, enumCB); @@ -1077,6 +1078,9 @@ static void AttachmentTest7(void) ok(num == 0, "Second mip level has %d surfaces attached, expected 1\n", num); /* Done level 2 */ /* Mip level 3 is still needed */ + hr = IDirectDrawSurface7_GetAttachedSurface(surface3, &caps, &surface4); + ok(hr == DDERR_NOTFOUND, "GetAttachedSurface returned %08x\n", hr); + ok(!surface4, "expected NULL pointer\n"); /* Try to attach a 16x16 miplevel - Should not work as far I can see */ memset(&ddsd, 0, sizeof(ddsd)); -- 2.11.4.GIT