On 11/3/09 1:53 PM, Georgios Petasis wrote:
It might help to carefully trace through the functions you're
executing. I can't tell from here which they are, but for example
Browser::GetEncoder leaks |doc|. Browser::SaveDocument leaks |document|.
Can you please suggest what is the correct way to call GetEncoder?
It's not how you call it. It's what the function does:
1208 nsIDOMDocument *doc;
1209 mNavigation->GetDocument(&doc);
That call just incremented the refcount by 1.
1210 if (doc) doc->AddRef();
And now you've incremented it by 2.
1211 NS_ConvertASCIItoUTF16 newContentType(formatType);
1212 rv = encoder->Init(doc, newContentType, encodingFlags);
1213 if (doc) doc->Release();
And now it's back to only being incremented by 1. But that 1 is never
released anywhere I see. I have no idea why you aren't using nsCOMPtr
here; it's designed to prevent just such mistakes.
Am I still leaking |doc|?
Yes, see above.
Have I forgot to release anything?
Yes, see above.
"get_document" simply calls Browser::GetProxyForDocument.
OK, that should be fine.
-Boris
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding