[PATCH 3/4] ddraw: Don't read clipper methods from the vtable.

Henri Verbeet hverbeet at gmail.com
Wed Mar 13 10:46:35 CDT 2019


On Wed, 13 Mar 2019 at 15:48, Stefan Dösinger <stefan at codeweavers.com> wrote:
>  struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
>  {
> +    struct ddraw_clipper *clipper;
> +
>      if (!iface)
>          return NULL;
> -    assert(iface->lpVtbl == &ddraw_clipper_vtbl);
>
> -    return impl_from_IDirectDrawClipper(iface);
> +    clipper = impl_from_IDirectDrawClipper(iface);
> +
> +    if (!clipper || iface->lpVtbl != &ddraw_clipper_vtbl)
> +        WARN("The application passed us a bad clipper object.\n");
> +
> +    return clipper;
>  }
"if (!ddraw_clipper_is_valid(clipper)) return NULL;", right?

> +/* Invoke clipper methods directly instead of going through the vtable. Clipper methods have
> + * protections against invalid clipper objects, but that won't work if we crash when reading
> + * the vtable. */
Sure, but that protection involves pretty much just calling
ddraw_clipper_is_valid(). Just calling that function in the
appropriate place in e.g. ddraw_surface_blt_clipped() seems both nicer
and more robust.



More information about the wine-devel mailing list