Rémi Bernon (@rbernon) commented about dlls/graphicscapture/session.c:
+static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) +{
- struct session *impl = impl_from_IActivationFactory( iface );
- ULONG ref = InterlockedIncrement( &impl->ref );
- TRACE( "iface %p increasing refcount to %lu.\n", iface, ref );
- return ref;
+}
+static ULONG WINAPI factory_Release( IActivationFactory *iface ) +{
- struct session *impl = impl_from_IActivationFactory( iface );
- ULONG ref = InterlockedDecrement( &impl->ref );
- TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
- if (!ref) free( impl );
You shouldn't do that here, the object is static and has not been allocated dynamically. Just return the refcount, it doesn't matter very much that it starts to 0.
You might even decide to break that test and start from 1 for consistency, though there's not much of a reason to do so either. Ref count tests are usually not even that important, and are there only to help tracking down leaks, which we don't even care about when it's for static objects like activation factories.
In this case it might indicate that the factory isn't supposed to be static, but I don't think we should do that.