Bug 556355 - Make sure the nsIMsgSend doesn't go away before we're done. r=m_kato a=jorgk
authorJorg K <jorgk@jorgk.com>
Tue, 20 Mar 2018 11:48:32 +0100
changeset 30533 5074b2ccb931aee4ba766f7cb724bc91a1b30fce
parent 30532 fa02a628315c211c3abab69f68334a5632577147
child 30534 4a08421a80cefbdfac98be07709687f69757c18e
push idunknown
push userunknown
push dateunknown
reviewersm_kato, jorgk
bugs556355
Bug 556355 - Make sure the nsIMsgSend doesn't go away before we're done. r=m_kato a=jorgk
mailnews/compose/src/nsMsgAttachmentHandler.cpp
mailnews/compose/src/nsMsgSend.cpp
--- a/mailnews/compose/src/nsMsgAttachmentHandler.cpp
+++ b/mailnews/compose/src/nsMsgAttachmentHandler.cpp
@@ -1360,20 +1360,11 @@ nsMsgAttachmentHandler::GetMimeDeliveryS
   NS_ENSURE_ARG(_retval);
   NS_IF_ADDREF(*_retval = m_mime_delivery_state);
   return NS_OK;
 }
 
 nsresult
 nsMsgAttachmentHandler::SetMimeDeliveryState(nsIMsgSend* mime_delivery_state)
 {
-  /*
-    Because setting m_mime_delivery_state to null could destroy ourself as
-    m_mime_delivery_state it's our parent, we need to protect ourself against
-    that!
-
-    This extra comptr is necessary,
-    see bug http://bugzilla.mozilla.org/show_bug.cgi?id=78967
-  */
-  nsCOMPtr<nsIMsgSend> temp = m_mime_delivery_state; /* Should lock our parent until the end of the function */
   m_mime_delivery_state = mime_delivery_state;
   return NS_OK;
 }
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -424,16 +424,18 @@ void nsMsgComposeAndSend::GenerateMessag
 /* All of the desired attachments have been written to individual temp files,
    and we know what's in them.  Now we need to make a final temp file of the
    actual mail message, containing all of the other files after having been
    encoded as appropriate.
  */
 NS_IMETHODIMP
 nsMsgComposeAndSend::GatherMimeAttachments()
 {
+  nsCOMPtr<nsIMsgSend> kungFuDeathGrip(this);
+
   bool shouldDeleteDeliveryState = true;
   nsresult status;
   uint32_t    i;
   PRFileDesc  *in_file = 0;
   char *buffer = 0;
   nsString msg;
   bool body_is_us_ascii = true;
   bool isUsingQP = false;