Commit 347efb98 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw: Don't operate on stored invalid clippers.

parent 7593a754
...@@ -33,7 +33,7 @@ static inline struct ddraw_clipper *impl_from_IDirectDrawClipper(IDirectDrawClip ...@@ -33,7 +33,7 @@ static inline struct ddraw_clipper *impl_from_IDirectDrawClipper(IDirectDrawClip
return CONTAINING_RECORD(iface, struct ddraw_clipper, IDirectDrawClipper_iface); 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 /* 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 * points to something that is either not accessible or not a clipper, or if you break
......
...@@ -391,6 +391,7 @@ struct ddraw_clipper ...@@ -391,6 +391,7 @@ struct ddraw_clipper
HRESULT ddraw_clipper_init(struct ddraw_clipper *clipper) DECLSPEC_HIDDEN; HRESULT ddraw_clipper_init(struct ddraw_clipper *clipper) DECLSPEC_HIDDEN;
struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) 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 * IDirectDrawPalette implementation structure
......
...@@ -1549,6 +1549,12 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons ...@@ -1549,6 +1549,12 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons
return hr; 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_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); 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 ...@@ -4426,7 +4432,8 @@ static HRESULT WINAPI ddraw_surface7_GetClipper(IDirectDrawSurface7 *iface, IDir
} }
*clipper = &surface->clipper->IDirectDrawClipper_iface; *clipper = &surface->clipper->IDirectDrawClipper_iface;
IDirectDrawClipper_AddRef(*clipper); if (ddraw_clipper_is_valid(surface->clipper))
IDirectDrawClipper_AddRef(*clipper);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return DD_OK; return DD_OK;
...@@ -4501,7 +4508,7 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface, ...@@ -4501,7 +4508,7 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
if (clipper != NULL) if (clipper != NULL)
IDirectDrawClipper_AddRef(iclipper); IDirectDrawClipper_AddRef(iclipper);
if (old_clipper) if (old_clipper && ddraw_clipper_is_valid(old_clipper))
IDirectDrawClipper_Release(&old_clipper->IDirectDrawClipper_iface); IDirectDrawClipper_Release(&old_clipper->IDirectDrawClipper_iface);
if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && This->ddraw->wined3d_swapchain) 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 ...@@ -5782,7 +5789,7 @@ static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *paren
/* Reduce the ddraw surface count. */ /* Reduce the ddraw surface count. */
list_remove(&surface->surface_list_entry); list_remove(&surface->surface_list_entry);
if (surface->clipper) if (surface->clipper && ddraw_clipper_is_valid(surface->clipper))
IDirectDrawClipper_Release(&surface->clipper->IDirectDrawClipper_iface); IDirectDrawClipper_Release(&surface->clipper->IDirectDrawClipper_iface);
if (surface == surface->ddraw->primary) if (surface == surface->ddraw->primary)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment