Bug 1495793 - Follow-up: Move null check right before dereferencing to avoid behaviour change. r=mkmelin
authorJorg K <jorgk@jorgk.com>
Thu, 04 Oct 2018 09:30:00 +0200
changeset 33303 9766dccdd8b8e23e7ac26f3bfa94449e8b5bf40d
parent 33302 042d0c2e51531351740c75b4b13e11430bbe6961
child 33304 ff185577e79d45203202dd6e9f587fa6888a505a
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersmkmelin
bugs1495793
Bug 1495793 - Follow-up: Move null check right before dereferencing to avoid behaviour change. r=mkmelin
mailnews/mime/src/nsStreamConverter.cpp
--- a/mailnews/mime/src/nsStreamConverter.cpp
+++ b/mailnews/mime/src/nsStreamConverter.cpp
@@ -848,18 +848,16 @@ nsStreamConverter::GetOrigMsgHdr(nsIMsgD
 //
 nsresult
 nsStreamConverter::OnDataAvailable(nsIRequest     *request,
                                    nsISupports    *ctxt,
                                    nsIInputStream *aIStream,
                                    uint64_t       sourceOffset,
                                    uint32_t       aLength)
 {
-  NS_ENSURE_TRUE(aIStream, NS_ERROR_NULL_POINTER);
-
   nsresult        rc=NS_OK;     // should this be an error instead?
   uint32_t        readLen = aLength;
   uint32_t        written;
 
   // If this is the first time through and we are supposed to be
   // outputting the wrapper two pane URL, then do it now.
   if (mWrapperOutput)
   {
@@ -880,16 +878,17 @@ const char output[] = "\
 
     if (mEmitter)
       mEmitter->Write(nsDependentCString(outBuf), &written);
 
     // rhp: will this stop the stream???? Not sure.
     return NS_ERROR_FAILURE;
   }
 
+  NS_ENSURE_TRUE(aIStream, NS_ERROR_NULL_POINTER);
   char *buf = (char *)PR_Malloc(aLength);
   if (!buf)
     return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
 
   readLen = aLength;
   aIStream->Read(buf, aLength, &readLen);
 
   // We need to filter out any null characters else we will have a lot of trouble