1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-28 16:02:29 +01:00

fix DeleteAttachedSurface and add some NULL checks

This commit is contained in:
FunkyFr3sh 2021-05-06 01:24:07 +02:00
parent 442b6c3f57
commit 63c4e6ff57

View File

@ -14,6 +14,8 @@
HRESULT dds_AddAttachedSurface(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE lpDDSurface) HRESULT dds_AddAttachedSurface(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE lpDDSurface)
{ {
if (lpDDSurface)
{
IDirectDrawSurface_AddRef(lpDDSurface); IDirectDrawSurface_AddRef(lpDDSurface);
if (g_ddraw->backbuffer && !This->backbuffer) if (g_ddraw->backbuffer && !This->backbuffer)
@ -23,6 +25,7 @@ HRESULT dds_AddAttachedSurface(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE
This->backbuffer = surface; This->backbuffer = surface;
} }
}
return DD_OK; return DD_OK;
} }
@ -611,7 +614,12 @@ HRESULT dds_BltFast(IDirectDrawSurfaceImpl *This, DWORD dst_x, DWORD dst_y, LPDI
HRESULT dds_DeleteAttachedSurface(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSurface) HRESULT dds_DeleteAttachedSurface(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSurface)
{ {
if (lpDDSurface)
{
IDirectDrawSurface_Release(lpDDSurface); IDirectDrawSurface_Release(lpDDSurface);
This->backbuffer = NULL;
}
return DD_OK; return DD_OK;
} }