Fixing "rampant leaks" when handing the sink to the parser when there
is no docshell present.

--pete
This commit is contained in:
pete%alphanumerica.com 2003-08-18 19:02:58 +00:00
Родитель 3027ba5b8a
Коммит 26f8f671c5
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -659,6 +659,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIXMLContentSink> sink;
PRBool hasDocShell(PR_TRUE);
if (aSink) {
sink = do_QueryInterface(aSink);
@ -669,6 +670,9 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
docShell = do_QueryInterface(aContainer);
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
}
if (!docShell)
hasDocShell = PR_FALSE;
rv = NS_NewXMLContentSink(getter_AddRefs(sink), this, aUrl, docShell,
aChannel);
NS_ENSURE_SUCCESS(rv, rv);
@ -681,7 +685,11 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
SetDocumentCharacterSet(charset);
parser->SetDocumentCharset(charset, charsetSource);
parser->SetCommand(aCommand);
parser->SetContentSink(sink);
// XXX This is a fix for bug #206947
// Handing the sink to the parser when there is
// no docshell causes rampant leaks --pete
if (hasDocShell)
parser->SetContentSink(sink);
parser->Parse(aUrl, nsnull, PR_FALSE, (void *)this);
return NS_OK;