From 47859e0b681fc3b1840ac38c65b80f5c57ad7597 Mon Sep 17 00:00:00 2001 From: "jefft%netscape.com" Date: Sat, 11 Sep 1999 01:44:16 +0000 Subject: [PATCH] fixed bug 12459 -- cannot use delete for error recovery instead should use AddRef() and Release() --- mailnews/compose/src/nsMsgAttachmentHandler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mailnews/compose/src/nsMsgAttachmentHandler.cpp b/mailnews/compose/src/nsMsgAttachmentHandler.cpp index d72d5a94c65d..0aa52919ef77 100644 --- a/mailnews/compose/src/nsMsgAttachmentHandler.cpp +++ b/mailnews/compose/src/nsMsgAttachmentHandler.cpp @@ -590,10 +590,15 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields) } NS_ADDREF(mURL); + // *** bug 12459 - bad web page url causes system to crash + // *** jefft -- We cannot use delete if FireURLRequest() failed. The reason + // someone in the food chain could destroy the object through AddRef() & + // Release(). We should use AddRef() and Release() for error recovery too. + NS_ADDREF(mFetcher); status = mFetcher->FireURLRequest(mURL, mOutFile, FetcherURLDoneCallback, this); if (NS_FAILED(status)) { - delete mFetcher; + NS_RELEASE(mFetcher); mFetcher = nsnull; return NS_ERROR_UNEXPECTED; }