Bug 1495793 - Fix crash in nsStreamConverter::OnDataAvailable(). r=mkmelin a=jorgk
authorJorg K <jorgk@jorgk.com>
Thu, 04 Oct 2018 17:46:30 +0200
changeset 31842 c25d2ff48b8166853fd0234af7b2dcec2dcb5ff0
parent 31841 6e5794497bbb1d61772a15439b697e3f1b0c59fc
child 31843 f4245553ba1a7c8893f41ce8e0680af0703a9b7f
push id85
push usermozilla@jorgk.com
push dateSun, 07 Oct 2018 09:37:17 +0000
treeherdercomm-esr60@147e5e18d4ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1495793
Bug 1495793 - Fix crash in nsStreamConverter::OnDataAvailable(). r=mkmelin a=jorgk * * * 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
@@ -886,16 +886,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