[PATCH 4/5] user32: Guard offscreen surface functions against non-offscreen surfaces (GCC 11).

Zebediah Figura zfigura at codeweavers.com
Mon Sep 27 11:18:06 CDT 2021


On 9/27/21 3:58 AM, Rémi Bernon wrote:
> Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
> ---
>   dlls/user32/win.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/dlls/user32/win.c b/dlls/user32/win.c
> index 7c2471d2746..ca758a535b1 100644
> --- a/dlls/user32/win.c
> +++ b/dlls/user32/win.c
> @@ -614,10 +614,15 @@ static inline void reset_bounds( RECT *bounds )
>   
>   static struct offscreen_window_surface *impl_from_window_surface( struct window_surface *base )
>   {
> -    if (!base || base->funcs != &offscreen_window_surface_funcs) return NULL;
>       return CONTAINING_RECORD( base, struct offscreen_window_surface, header );
>   }
>   
> +static struct offscreen_window_surface *impl_from_window_surface_or_null( struct window_surface *base )
> +{
> +    if (!base || base->funcs != &offscreen_window_surface_funcs) return NULL;
> +    return impl_from_window_surface( base );
> +}
> +

FWIW, in d3d code that's called "unsafe_impl_from_window_surface".

>   static void CDECL offscreen_window_surface_lock( struct window_surface *base )
>   {
>       struct offscreen_window_surface *impl = impl_from_window_surface( base );
> @@ -687,7 +692,7 @@ void create_offscreen_window_surface( const RECT *visible_rect, struct window_su
>       surface_rect.bottom = (surface_rect.bottom + 0x1f) & ~0x1f;
>   
>       /* check that old surface is an offscreen_window_surface, or release it */
> -    if ((impl = impl_from_window_surface( *surface )))
> +    if ((impl = impl_from_window_surface_or_null( *surface )))
>       {
>           /* if the rect didn't change, keep the same surface */
>           if (EqualRect( &surface_rect, &impl->header.rect )) return;
> 



More information about the wine-devel mailing list