Bug 1328569 - Don't call UnmapViewOfFile() with a null address. r?froydnj draft
authorCervantes Yu <cyu@mozilla.com>
Wed, 04 Jan 2017 18:42:51 +0800
changeset 455847 363e3e3dace395cb8903f3dc719c12d1c835678f
parent 455536 57ac9f63fc6953f4efeb0cc84a60192d3721251f
child 541057 640fbeab2d59060be9e6f350fc110bfa72244b2b
push id40310
push usercyu@mozilla.com
push dateWed, 04 Jan 2017 10:47:33 +0000
reviewersfroydnj
bugs1328569
milestone53.0a1
Bug 1328569 - Don't call UnmapViewOfFile() with a null address. r?froydnj MozReview-Commit-ID: Ca5n8rSXQ4x
xpcom/io/FileUtilsWin.cpp
--- a/xpcom/io/FileUtilsWin.cpp
+++ b/xpcom/io/FileUtilsWin.cpp
@@ -4,32 +4,35 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "FileUtilsWin.h"
 
 #include <windows.h>
 #include <psapi.h>
 
+#include "mozilla/Unused.h"
 #include "nsWindowsHelpers.h"
 #include "GeckoProfiler.h"
 
 namespace {
 
 // Scoped type used by HandleToFilename
 struct ScopedMappedViewTraits
 {
   typedef void* type;
   static void* empty()
   {
     return nullptr;
   }
   static void release(void* aPtr)
   {
-    UnmapViewOfFile(aPtr);
+    if (aPtr) {
+      mozilla::Unused << UnmapViewOfFile(aPtr);
+    }
   }
 };
 typedef mozilla::Scoped<ScopedMappedViewTraits> ScopedMappedView;
 
 } // namespace
 
 namespace mozilla {