On Wed, 13 Mar 2019 at 15:48, Stefan Dösinger stefan@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.