The difference between assignment and attachment with ATL smart pointers
Last time, I presented a puzzle regarding a memory leak. Here's the relevant code fragment: The problem here is assigning the return value of to a smart pointer instead of attaching it. The function creates a memory stream and returns a pointer to it. That pointer has a reference count of one, in accordance with COM rules that a function ...