Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IUnknown* B;
- IUnknown* C;
- A->QueryInterface(IID_ISomeInterface, (void**)B);
- // B refcount = 1.
- A->QueryInterface(IID_ISomeInterface, (void**)C);
- // C refcount = 1, B refcount unchanged.
- C->Release();
- // C refcount = 0, C is destroyed, B refcount unchanged.
- C->SomeMethod(); // Will crash as C has been destroyed, even though there is an outstanding 'live' ISomeInterface instance on the same object (i.e. B).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement