Bug 912465 - Use MsgNewSafeBufferedFileOutputStream instead of NewLocalFileOutputStream in nsPop3Protocol.cpp. r=irving
authorJohannes Buchner <buchner.johannes@gmx.at>
Thu, 21 Nov 2013 09:02:47 -0500
changeset 13300 25b09e25e7de
parent 13299 7b725655e48f
child 13301 d7853d9e9971
push id9665
push userryanvm@gmail.com
push dateThu, 21 Nov 2013 14:03:18 +0000
treeherdercomm-central@d7853d9e9971 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersirving
bugs912465
Bug 912465 - Use MsgNewSafeBufferedFileOutputStream instead of NewLocalFileOutputStream in nsPop3Protocol.cpp. r=irving
mailnews/local/src/nsPop3Protocol.cpp
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -348,17 +348,23 @@ net_pop3_write_state(Pop3UidlHost* host,
       fileOutputStream->Write(host->host, strlen(host->host), &numBytesWritten);
       fileOutputStream->Write(" ", 1, &numBytesWritten);
       fileOutputStream->Write(host->user, strlen(host->user), &numBytesWritten);
       fileOutputStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &numBytesWritten);
       PL_HashTableEnumerateEntries(host->hash, net_pop3_write_mapper, (void *)fileOutputStream);
     }
   }
   nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(fileOutputStream);
-  safeStream->Finish();
+  NS_ASSERTION(safeStream, "expected a safe output stream!");
+  if (safeStream) {
+    rv = safeStream->Finish();
+    if (NS_FAILED(rv)) {
+      NS_WARNING("failed to save pop state! possible data loss");
+    }
+  }
 }
 
 static void
 net_pop3_free_state(Pop3UidlHost* host)
 {
   Pop3UidlHost* h;
   while (host)
   {