Bug 906469 - fix maildir crash while parsing a folder. r=jorgk
authorR Kent James <kent@caspia.com>
Sun, 16 Dec 2018 13:28:00 +0100
changeset 33161 e756111cbbd0
parent 33160 f245d6f5d3b3
child 33162 714714d80d62
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs906469
Bug 906469 - fix maildir crash while parsing a folder. r=jorgk
mailnews/local/src/nsMsgMaildirStore.cpp
--- a/mailnews/local/src/nsMsgMaildirStore.cpp
+++ b/mailnews/local/src/nsMsgMaildirStore.cpp
@@ -1184,16 +1184,17 @@ MaildirStoreParser::MaildirStoreParser(n
 
 MaildirStoreParser::~MaildirStoreParser()
 {
 }
 
 nsresult MaildirStoreParser::ParseNextMessage(nsIFile *aFile)
 {
   nsresult rv;
+  NS_ENSURE_TRUE(m_db, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIInputStream> inputStream;
   nsCOMPtr<nsIMsgParseMailMsgState> msgParser =
     do_CreateInstance(NS_PARSEMAILMSGSTATE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   msgParser->SetMailDB(m_db);
   nsCOMPtr<nsIMsgDBHdr> newMsgHdr;
   rv = m_db->CreateNewHdr(nsMsgKey_None, getter_AddRefs(newMsgHdr));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1266,19 +1267,20 @@ void MaildirStoreParser::TimerCallback(n
       }
     }
     // Parsing complete and timer cancelled, so we release the parser object.
     delete parser;
     return;
   }
   nsCOMPtr<nsIFile> currentFile;
   nsresult rv = parser->m_directoryEnumerator->GetNextFile(getter_AddRefs(currentFile));
-  NS_ENSURE_SUCCESS_VOID(rv);
-  parser->ParseNextMessage(currentFile);
-  // ### TODO - what if this fails?
+  if (NS_SUCCEEDED(rv))
+    rv = parser->ParseNextMessage(currentFile);
+  if (NS_FAILED(rv) && parser->m_listener)
+    parser->m_listener->OnStopRunningUrl(nullptr, NS_ERROR_FAILURE);
 }
 
 nsresult MaildirStoreParser::StartTimer()
 {
   nsresult rv;
   m_timer = do_CreateInstance("@mozilla.org/timer;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   m_timer->InitWithNamedFuncCallback(TimerCallback, (void *) this, 0,