TDocManager::InitDoc claims, and it is assumed by callers, that on failure, it will take ownership of the given TDocument, delete it and return nullptr. However, in some circumstances, InitDoc may return nullptr without deleting the given document. In particular, if TDocument::GetTemplate or TDocTemplate::GetFileFilter fails, or unless dtAutoDelete is set, if TDocument::CreateView fails, the document will not be deleted. Callers do not handle this (see TDocManager::CreateDoc), nor can they do so, since distinguishing these special cases in any way is not possible. So in these cases, the document will dangle.
This issue has been fixed on the trunk [r3450], and the fix has been merged into Owlet [r3451].
Related
Commit: [r3450]
Commit: [r3451]