Bug 1373970 - Avoid null pointer deref. r=bagder
authorValentin Gosu <valentin.gosu@gmail.com>
Sun, 18 Jun 2017 21:17:56 +0200
changeset 364699 161c7a2d4b2993749bd56fb5b0adc7b0db9ec388
parent 364698 e9683155991f5c099075da2413c360e95681fc6b
child 364700 7c5e6e176f185d8b78e4a564ffb5d8a7a8fe1bc2
push id32053
push userkwierso@gmail.com
push dateTue, 20 Jun 2017 00:30:11 +0000
treeherdermozilla-central@416c3c8c4b3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbagder
bugs1373970
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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