Bug 1571813 - do not assign a non-existent array elements in nsMsgSend::HackAttachments() and nsAbView::SwapFirstNameLastName(). r+a=jorgk
authoraceman <acelists@atlas.sk>
Wed, 21 Aug 2019 09:30:43 +0200
changeset 36176 979207319f7a0eed4b9615cb5d56fb3c354b3df2
parent 36175 1e92fa2aab3f6481a1e2f28a4cce11370328a2a6
child 36177 7b046aa7c4afc118571eafe4674d3ae65d83558b
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
bugs1571813
Bug 1571813 - do not assign a non-existent array elements in nsMsgSend::HackAttachments() and nsAbView::SwapFirstNameLastName(). r+a=jorgk
mailnews/addrbook/src/nsAbView.cpp
mailnews/compose/src/nsMsgSend.cpp
--- a/mailnews/addrbook/src/nsAbView.cpp
+++ b/mailnews/addrbook/src/nsAbView.cpp
@@ -1245,18 +1245,18 @@ NS_IMETHODIMP nsAbView::SwapFirstNameLas
 
             // The format should stays the same before/after we swap the names
             formatString = displayNameLastnamefirst ? "lastFirstFormat"
                                                     : "firstLastFormat";
 
             // Generate both ln/fn and fn/ln combination since we need both
             // later to check to see if the current display name was edited note
             // that fn/ln still hold the values before the swap
-            nameString[0] = ln;
-            nameString[1] = fn;
+            nameString.AppendElement(ln);
+            nameString.AppendElement(fn);
             rv = bundle->FormatStringFromName(formatString, nameString, dnLnFn);
             NS_ENSURE_SUCCESS(rv, rv);
             nameString[0] = fn;
             nameString[1] = ln;
             rv = bundle->FormatStringFromName(formatString, nameString, dnFnLn);
             NS_ENSURE_SUCCESS(rv, rv);
 
             // Get the current display name
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -2224,17 +2224,17 @@ nsresult nsMsgComposeAndSend::HackAttach
       AutoTArray<nsString, 1> formatParams;
       if (!(m_attachments[i]->m_realName).IsEmpty()) {
         CopyUTF8toUTF16(m_attachments[i]->m_realName,
                         *formatParams.AppendElement());
       } else if (m_attachments[i]->mURL) {
         nsCString asciiSpec;
         m_attachments[i]->mURL->GetAsciiSpec(asciiSpec);
         attachmentFileName.AssignASCII(asciiSpec.get());
-        formatParams[0] = attachmentFileName;
+        formatParams.AppendElement(attachmentFileName);
       }
       mComposeBundle->FormatStringFromName("gatheringAttachment", formatParams,
                                            msg);
 
       if (!msg.IsEmpty()) {
         SetStatusMessage(msg);
       }