Bug 1373970 - Avoid null pointer deref. r=bagder
authorValentin Gosu <valentin.gosu@gmail.com>
Sun, 18 Jun 2017 21:17:56 +0200
changeset 596634 161c7a2d4b2993749bd56fb5b0adc7b0db9ec388
parent 596633 e9683155991f5c099075da2413c360e95681fc6b
child 596635 7c5e6e176f185d8b78e4a564ffb5d8a7a8fe1bc2
push id64704
push userbmo:rail@mozilla.com
push dateMon, 19 Jun 2017 15:14:27 +0000
reviewersbagder
bugs1373970
milestone56.0a1
Bug 1373970 - Avoid null pointer deref. r=bagder MozReview-Commit-ID: BmcolZSrpIL
netwerk/base/nsFileStreams.cpp
--- a/netwerk/base/nsFileStreams.cpp
+++ b/netwerk/base/nsFileStreams.cpp
@@ -788,16 +788,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