Advertisement
Guest User

Untitled

a guest
Jul 31st, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. IUnknown* B;
  2. IUnknown* C;
  3. A->QueryInterface(IID_ISomeInterface, (void**)B);
  4. // B refcount = 1.
  5.  
  6. A->QueryInterface(IID_ISomeInterface, (void**)C);
  7. // C refcount = 1, B refcount unchanged.
  8.  
  9. C->Release();
  10. // C refcount = 0, C is destroyed, B refcount unchanged.
  11.  
  12. 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