Bug 1347868 - Fix crash when accessing last character of empty string. r=rkent a=jorgk
authorJorg K <jorgk@jorgk.com>
Thu, 16 Mar 2017 09:25:00 +0100
changeset 27810 061570ec12aa4a5e2b0e30f033a8235f0c72f7fe
parent 27809 82abbd50f22c0dd380fd5730e81b284b80cc186c
child 27811 33b3cac977d8c66e2e649176f691eddec3ddd573
push id1857
push usermozilla@jorgk.com
push dateMon, 20 Mar 2017 18:01:29 +0000
treeherdercomm-esr52@a730476809a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, jorgk
bugs1347868
Bug 1347868 - Fix crash when accessing last character of empty string. r=rkent a=jorgk
mailnews/mapi/mapihook/src/msgMapiHook.cpp
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -630,17 +630,17 @@ nsresult nsMapiHook::PopulateCompFieldsW
   // set body
   if (aMessage->lpszNoteText)
   {
     nsAutoString Body ;
     if (platformCharSet.IsEmpty())
       platformCharSet.Assign(nsMsgI18NFileSystemCharset());
     rv = ConvertToUnicode(platformCharSet.get(), (char *) aMessage->lpszNoteText, Body);
     if (NS_FAILED(rv)) return rv ;
-    if (Body.Last() != '\n')
+    if (Body.IsEmpty() || Body.Last() != '\n')
       Body.AppendLiteral(CRLF);
 
     rv = aCompFields->SetBody(Body) ;
   }
 
 #ifdef RAJIV_DEBUG
   // testing what all was set in CompFields
   printf ("To : %S \n", To.get()) ;