Put pointer test around smprintf to prevent crash for invalid IMG links.

b=40094,r=adamlock,approved valeski
This commit is contained in:
locka%iol.ie 2000-06-05 22:21:37 +00:00
Родитель 2af7bba123
Коммит c21b74ff21
2 изменённых файлов: 12 добавлений и 8 удалений

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

@ -1259,11 +1259,13 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,
NS_ConvertASCIItoUCS2("dnsNotFound").GetUnicode(),
getter_Copies(messageStr)), NS_ERROR_FAILURE);
PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host);
if (!msg) return NS_ERROR_OUT_OF_MEMORY;
if (host) {
PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host);
if (!msg) return NS_ERROR_OUT_OF_MEMORY;
prompter->Alert(nsnull, msg);
nsTextFormatter::smprintf_free(msg);
prompter->Alert(nsnull, msg);
nsTextFormatter::smprintf_free(msg);
}
}
else if(aStatus == NS_ERROR_CONNECTION_REFUSED)
{// Doc failed to load because we couldn't connect to the server.

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

@ -1259,11 +1259,13 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,
NS_ConvertASCIItoUCS2("dnsNotFound").GetUnicode(),
getter_Copies(messageStr)), NS_ERROR_FAILURE);
PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host);
if (!msg) return NS_ERROR_OUT_OF_MEMORY;
if (host) {
PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host);
if (!msg) return NS_ERROR_OUT_OF_MEMORY;
prompter->Alert(nsnull, msg);
nsTextFormatter::smprintf_free(msg);
prompter->Alert(nsnull, msg);
nsTextFormatter::smprintf_free(msg);
}
}
else if(aStatus == NS_ERROR_CONNECTION_REFUSED)
{// Doc failed to load because we couldn't connect to the server.