Bug 795707 Selecting multiple PGP/MIME encrypted messages crashes Thunderbird. Create an individual object for each message instead of calling a service. r+a=Standard8
authorPatrick Brunschwig <patrick@enigmail.net>
Mon, 01 Oct 2012 14:47:09 +0100
changeset 13032 e53b1c5df7f1ea4b24a4fb0d978595466dbf6420
parent 13031 0d4f11976e39db364b7491b90e6ea2b16f9653c1
child 13033 b405050a39c2be458d160980b3f350f8bc5aa824
push idunknown
push userunknown
push dateunknown
bugs795707
Bug 795707 Selecting multiple PGP/MIME encrypted messages crashes Thunderbird. Create an individual object for each message instead of calling a service. r+a=Standard8
mailnews/mime/cthandlers/pgpmime/nsPgpMimeProxy.cpp
mailnews/mime/cthandlers/pgpmime/nsPgpMimeProxy.h
--- a/mailnews/mime/cthandlers/pgpmime/nsPgpMimeProxy.cpp
+++ b/mailnews/mime/cthandlers/pgpmime/nsPgpMimeProxy.cpp
@@ -144,17 +144,17 @@ MimePgpe_init(MimeObject *obj,
   NS_ENSURE_TRUE(data, nsnull);
 
   data->self = obj;
   data->output_fn = output_fn;
   data->output_closure = output_closure;
   data->mimeDecrypt = nsnull;
 
   nsresult rv;
-  data->mimeDecrypt = do_GetService(NS_PGPMIMEPROXY_CONTRACTID, &rv);
+  data->mimeDecrypt = do_CreateInstance(NS_PGPMIMEPROXY_CONTRACTID, &rv);
   if (NS_FAILED(rv))
     return data;
 
   char *ct = MimeHeaders_get(obj->headers, HEADER_CONTENT_TYPE, false, false);
 
   rv = (ct ? data->mimeDecrypt->SetContentType(nsDependentCString(ct))
         : data->mimeDecrypt->SetContentType(EmptyCString()));
 
@@ -272,16 +272,20 @@ nsPgpMimeProxy::Init()
 {
   mByteBuf.Truncate();
 
   nsresult rv;
   nsCOMPtr<nsIPrefBranch> pbi(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   if (NS_FAILED(rv))
     return rv;
 
+  mDecryptor = do_CreateInstance(PGPMIME_JS_DECRYPTOR_CONTRACTID, &rv);
+  if (NS_FAILED(rv))
+    mDecryptor = nullptr;
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPgpMimeProxy::Write(const char *buf, PRUint32 buf_size)
 {
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
--- a/mailnews/mime/cthandlers/pgpmime/nsPgpMimeProxy.h
+++ b/mailnews/mime/cthandlers/pgpmime/nsPgpMimeProxy.h
@@ -7,25 +7,25 @@
 
 #include "mimecth.h"
 #include "nsIPgpMimeProxy.h"
 #include "nsCOMPtr.h"
 #include "nsIStreamListener.h"
 #include "nsIInputStream.h"
 #include "nsILoadGroup.h"
 
+#define PGPMIME_JS_DECRYPTOR_CONTRACTID "@mozilla.org/mime/pgp-mime-js-decrypt;1"
+
 typedef struct MimeEncryptedPgpClass MimeEncryptedPgpClass;
 typedef struct MimeEncryptedPgp      MimeEncryptedPgp;
 
 struct MimeEncryptedPgpClass {
   MimeEncryptedClass encrypted;
 };
 
-//extern MimeEncryptedPgpClass mimeEncryptedPgpClass;
-
 struct MimeEncryptedPgp {
   MimeEncrypted encrypted;
 };
 
 class nsPgpMimeProxy : public nsIPgpMimeProxy,
                        public nsIRequest,
                        public nsIInputStream
 {