Bug 956961 - FileDescriptorToFILE should always use its input. r=bent
authorJed Davis <jld@mozilla.com>
Wed, 02 Jul 2014 11:22:40 -0700
changeset 192044 f46f5f29bd86e21c56a5de16a9fa325ea198c72b
parent 192043 0072f8f779415817ab9ae68cbb914c21ff724645
child 192045 35790c8d0aaf0a94af3d6fcc096ae2fdf58eb7a9
push id45736
push userjedavis@mozilla.com
push dateThu, 03 Jul 2014 05:17:05 +0000
treeherdermozilla-inbound@63538074b343 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs956961
milestone33.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 956961 - FileDescriptorToFILE should always use its input. r=bent
ipc/glue/FileDescriptorUtils.cpp
--- a/ipc/glue/FileDescriptorUtils.cpp
+++ b/ipc/glue/FileDescriptorUtils.cpp
@@ -86,21 +86,23 @@ CloseFileRunnable::Run()
 
 namespace mozilla {
 namespace ipc {
 
 FILE*
 FileDescriptorToFILE(const FileDescriptor& aDesc,
                      const char* aOpenMode)
 {
+  // Debug builds check whether the handle was "used", even if it's
+  // invalid, so that needs to happen first.
+  FileDescriptor::PlatformHandleType handle = aDesc.PlatformHandle();
   if (!aDesc.IsValid()) {
     errno = EBADF;
     return nullptr;
   }
-  FileDescriptor::PlatformHandleType handle = aDesc.PlatformHandle();
 #ifdef XP_WIN
   int fd = _open_osfhandle(reinterpret_cast<intptr_t>(handle), 0);
   if (fd == -1) {
     CloseHandle(handle);
     return nullptr;
   }
 #else
   int fd = handle;