On 4 September 2014 13:18, Stefan Dösinger stefan@codeweavers.com wrote:
dds_get_outer AddRefs the inner surface when it creates the wrapper surface. The wrapper releases only one reference when it is destroyed, leaking one of the two. AddRefing in dds_get_outer makes sense because this is also used by e.g. GetAttachedSurface, where it creates a new wrapper for surfaces ddrawex didn't know about yet.
Whether native ddrawex.dll properly handles GetAttachedSurfaces and friends is an open question. We already know it doesn't properly handle IDirectDraw4::GetSurfaceFromDC, even though the equivalent ddraw3 method works.
On a related note, I think it's unfortunate that dds_get_outer() creates a wrapper surface with refcount 1 if it doesn't exist yet, but doesn't AddRef() existing interfaces when returning them. That means the caller effectively needs to know if the wrapper already exists or not in order to do proper refcounting.