Bug 1373970 - Avoid null pointer deref. r=bagder, a=gchang
authorValentin Gosu <valentin.gosu@gmail.com>
Sun, 18 Jun 2017 21:17:56 +0200
changeset 356063 8321ef71adb5fec6ac94b99b02261bd6511711c7
parent 356062 58a144bf9677b7161650a7e005aeec5013067ef2
child 356064 3f84d97b2d55febafee621eb949cdecffd452425
push id7196
push userryanvm@gmail.com
push dateFri, 07 Jul 2017 14:48:17 +0000
treeherdermozilla-esr52@322c18d011af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbagder, gchang
bugs1373970
milestone52.2.1
Bug 1373970 - Avoid null pointer deref. r=bagder, a=gchang MozReview-Commit-ID: BmcolZSrpIL
netwerk/base/nsFileStreams.cpp
--- a/netwerk/base/nsFileStreams.cpp
+++ b/netwerk/base/nsFileStreams.cpp
@@ -985,16 +985,19 @@ nsAtomicFileOutputStream::Init(nsIFile* 
 nsresult
 nsAtomicFileOutputStream::DoOpen()
 {
     // Make sure mOpenParams.localFile will be empty if we bail somewhere in
     // this function
     nsCOMPtr<nsIFile> file;
     file.swap(mOpenParams.localFile);
 
+    if (!file) {
+        return NS_ERROR_NOT_INITIALIZED;
+    }
     nsresult rv = file->Exists(&mTargetFileExists);
     if (NS_FAILED(rv)) {
         NS_ERROR("Can't tell if target file exists");
         mTargetFileExists = true; // Safer to assume it exists - we just do more work.
     }
 
     // follow symlinks, for two reasons:
     // 1) if a user has deliberately set up a profile file as a symlink, we honor it