fix crash during save as draft when error fetching attachment, bug 531262, r=neil
authorDavid Bienvenu <bienvenu@nventure.com>
Tue, 26 Apr 2011 08:37:14 -0700
changeset 7619 44696b7ee9593bb3872da8f3cdcf558339945672
parent 7618 c3eb66f60c2b6077be36cd6624a33b8f3cd78b52
child 7620 27b95c09e1bac189a08871e5d2fad0ae358da699
push id5844
push userbienvenu@nventure.com
push dateTue, 26 Apr 2011 15:37:02 +0000
treeherdercomm-central@44696b7ee959 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs531262
fix crash during save as draft when error fetching attachment, bug 531262, r=neil
mailnews/compose/src/nsMsgAttachmentHandler.cpp
mailnews/compose/src/nsMsgAttachmentHandler.h
--- a/mailnews/compose/src/nsMsgAttachmentHandler.cpp
+++ b/mailnews/compose/src/nsMsgAttachmentHandler.cpp
@@ -1128,30 +1128,31 @@ nsMsgAttachmentHandler::LoadDataFromFile
 
   PR_FREEIF(readBuf);
   return NS_OK;
 }
 
 nsresult
 nsMsgAttachmentHandler::Abort()
 {
+  nsCOMPtr<nsIRequest> saveRequest;
+  saveRequest.swap(mRequest);
   NS_ASSERTION(m_mime_delivery_state != nsnull, "not-null m_mime_delivery_state");
 
   if (m_done)
     return NS_OK;
 
-  if (mRequest)
-    return mRequest->Cancel(NS_ERROR_ABORT);
+  if (saveRequest)
+    return saveRequest->Cancel(NS_ERROR_ABORT);
   else
     if (m_mime_delivery_state)
     {
       m_mime_delivery_state->SetStatus(NS_ERROR_ABORT);
       m_mime_delivery_state->NotifyListenerOnStopSending(nsnull, NS_ERROR_ABORT, 0, nsnull);
     }
-
   return NS_OK;
 
 }
 
 nsresult
 nsMsgAttachmentHandler::UrlExit(nsresult status, const PRUnichar* aMsg)
 {
   NS_ASSERTION(m_mime_delivery_state != nsnull, "not-null m_mime_delivery_state");
--- a/mailnews/compose/src/nsMsgAttachmentHandler.h
+++ b/mailnews/compose/src/nsMsgAttachmentHandler.h
@@ -126,17 +126,17 @@ private:
   PRBool HasResourceFork(FSRef *fsRef);
 #endif
 
   //
 public:
   nsCOMPtr <nsIURI> mURL;
   nsCOMPtr <nsILocalFile>        mTmpFile;         // The temp file to which we save it 
   nsCOMPtr<nsIOutputStream>  mOutFile;          
-  nsIRequest            *mRequest;          // The live request used while fetching an attachment
+  nsCOMPtr<nsIRequest> mRequest; // The live request used while fetching an attachment
   nsMsgCompFields       *mCompFields;       // Message composition fields for the sender
   PRBool                m_bogus_attachment; // This is to catch problem children...
   
 #ifdef XP_MACOSX
   // if we need to encode this file into for example an appledouble, or zip file,
   // this file is our working file. currently only needed on mac.
   nsCOMPtr<nsILocalFile> mEncodedWorkingFile;
 #endif