ddraw: Don't release ddraw if a surface is still using it.

Michael Karcher wine at mkarcher.dialup.fu-berlin.de
Sat May 31 07:57:25 CDT 2008


Am Samstag, den 31.05.2008, 12:08 +0200 schrieb Jens Albretsen:
The patch looks like it would work as advertised, but the following
snippet in the testcase smells fishy:

> +static unsigned long getRefcount(IUnknown *iface)
> +{
> +    IUnknown_AddRef(iface);
> +    return IUnknown_Release(iface);
> +}
[...]
> +    IDirectDraw_Release(lpDD);
> +
> +    ref = getRefcount(lpDD);
> +    ok(ref == 0, "Got refcount %ld, expected 0\n", ref);
> +
> +    IUnknown_Release(surface);

The IDirectDraw_Release seems to be dropping the reference count of the
DirectDraw object to zero. This is OK, of course, as you might well drop
the last reference. But this might put the DirectDraw object into a
state where AddRef crashes, as parts of the object might get destroyed
when the reference count drops down to zero.

On wine, there is obviously no problem, as wine keeps the DirectDraw
object itself alive for longer. On Windows, it is not clear to me that
the DirectDraw object is not destroyed at the IDirectDraw_Release, the
only thing we know is, that Direct Draw still is working (perhaps
implemented by a subobject of the DirectDraw object which keeps living).

I suggest to alternatively write the second part as

+    ref = IDirectDraw_Release(lpDD);
+    ok(ref == 0, "Got refcount %ld, expected 0\n", ref);
+
+    IUnknown_Release(surface);

Regards,
  Michael Karcher




More information about the wine-devel mailing list