ddraw: Don't operate on stored invalid clippers.

Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Stefan Dösinger 2019-03-22 12:50:04 +03:00 committed by Alexandre Julliard
parent 7593a7544d
commit 347efb985c
3 changed files with 12 additions and 4 deletions

View File

@ -33,7 +33,7 @@ static inline struct ddraw_clipper *impl_from_IDirectDrawClipper(IDirectDrawClip
return CONTAINING_RECORD(iface, struct ddraw_clipper, IDirectDrawClipper_iface);
}
static BOOL ddraw_clipper_is_valid(const struct ddraw_clipper *clipper)
BOOL ddraw_clipper_is_valid(const struct ddraw_clipper *clipper)
{
/* Native is very lenient when you invoke the clipper methods with a clipper pointer that
* points to something that is either not accessible or not a clipper, or if you break

View File

@ -391,6 +391,7 @@ struct ddraw_clipper
HRESULT ddraw_clipper_init(struct ddraw_clipper *clipper) DECLSPEC_HIDDEN;
struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) DECLSPEC_HIDDEN;
BOOL ddraw_clipper_is_valid(const struct ddraw_clipper *clipper) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirectDrawPalette implementation structure

View File

@ -1549,6 +1549,12 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons
return hr;
}
if (!ddraw_clipper_is_valid(dst_surface->clipper))
{
FIXME("Attempting to blit with an invalid clipper.\n");
return DDERR_INVALIDPARAMS;
}
scale_x = (float)(src_rect.right - src_rect.left) / (float)(dst_rect.right - dst_rect.left);
scale_y = (float)(src_rect.bottom - src_rect.top) / (float)(dst_rect.bottom - dst_rect.top);
@ -4426,7 +4432,8 @@ static HRESULT WINAPI ddraw_surface7_GetClipper(IDirectDrawSurface7 *iface, IDir
}
*clipper = &surface->clipper->IDirectDrawClipper_iface;
IDirectDrawClipper_AddRef(*clipper);
if (ddraw_clipper_is_valid(surface->clipper))
IDirectDrawClipper_AddRef(*clipper);
wined3d_mutex_unlock();
return DD_OK;
@ -4501,7 +4508,7 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
if (clipper != NULL)
IDirectDrawClipper_AddRef(iclipper);
if (old_clipper)
if (old_clipper && ddraw_clipper_is_valid(old_clipper))
IDirectDrawClipper_Release(&old_clipper->IDirectDrawClipper_iface);
if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && This->ddraw->wined3d_swapchain)
@ -5782,7 +5789,7 @@ static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *paren
/* Reduce the ddraw surface count. */
list_remove(&surface->surface_list_entry);
if (surface->clipper)
if (surface->clipper && ddraw_clipper_is_valid(surface->clipper))
IDirectDrawClipper_Release(&surface->clipper->IDirectDrawClipper_iface);
if (surface == surface->ddraw->primary)