Bug 694500 - crash CCompositionFile::EnsureHasDataInBuffer. r=dbienvenu, a=standard8
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 27 Oct 2011 10:07:41 +0900
changeset 8954 47af4afca66a7b1130676ad673fc7a8db69d9b08
parent 8953 6fc3c7961a451919971d9d24d98d78227a149a31
child 8955 e05b354769be4aad6a228341929cccb641222542
push id206
push userm_kato@ga2.so-net.ne.jp
push dateThu, 27 Oct 2011 01:12:20 +0000
treeherdercomm-beta@47af4afca66a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbienvenu, standard8
bugs694500
Bug 694500 - crash CCompositionFile::EnsureHasDataInBuffer. r=dbienvenu, a=standard8
mailnews/import/outlook/src/nsOutlookCompose.cpp
--- a/mailnews/import/outlook/src/nsOutlookCompose.cpp
+++ b/mailnews/import/outlook/src/nsOutlookCompose.cpp
@@ -114,17 +114,17 @@ static const char *p_test_body =
 
 // A replacement for SimpleBufferTonyRCopiedTwice round-robin buffer and ReadFileState classes
 class CCompositionFile {
 public:
   // fifoBuffer is used for memory allocation optimization
   // convertCRs controls if we want to convert standalone CRs to CRLFs
   CCompositionFile(nsIFile* aFile, void* fifoBuffer, PRUint32 fifoBufferSize, bool convertCRs=false);
 
-  operator bool() const { return m_fileSize; }
+  operator bool() const { return m_fileSize && m_pInputStream; }
 
   // Reads up to and including the term sequence, or entire file if term isn't found
   // termSize may be used to include NULLs in the terminator sequences.
   // termSize value of -1 means "zero-terminated string" -> size is calculated with strlen
   nsresult ToString(nsCString& dest, const char* term=0, int termSize=-1);
   nsresult ToStream(nsIOutputStream *dest, const char* term=0, int termSize=-1);
   char LastChar() { return m_lastChar; }
 private:
@@ -750,17 +750,17 @@ bool nsOutlookCompose::GenerateHackSeque
   return true;
 }
 // End Bug 593907
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 CCompositionFile::CCompositionFile(nsIFile* aFile, void* fifoBuffer,
                                    PRUint32 fifoBufferSize, bool convertCRs)
-  : m_pFile(aFile), m_fileReadPos(0),
+  : m_pFile(aFile), m_fileSize(0), m_fileReadPos(0),
     m_fifoBuffer(static_cast<char*>(fifoBuffer)),
     m_fifoBufferSize(fifoBufferSize),
     m_fifoBufferReadPos(static_cast<char*>(fifoBuffer)),
     m_fifoBufferWrittenPos(static_cast<char*>(fifoBuffer)),
     m_convertCRs(convertCRs),
     m_lastChar(0)
 {
   m_pFile->GetFileSize(&m_fileSize);