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 16918 25b09e25e7de4d1231be92c9456e5b8af4a68ec8
parent 16917 7b725655e48f3251c04be3cdd54cf70bc310f6b8
child 16919 d7853d9e99714facb11511efa9f6a03bf9c08814
push id1074
push userbugzilla@standard8.plus.com
push dateMon, 03 Feb 2014 22:47:23 +0000
treeherdercomm-beta@6b791b5369ed [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)
   {