Bug 1188186 - Fix leak of FDs in |CreateTransport|. r=bds
authorPaul Bignier <paul.bignier@gmail.com>
Fri, 04 Dec 2015 00:23:00 +0100
changeset 310221 b0da06541b8278c1827a5f11f5f65b9b0abbe417
parent 310220 65bc8bf4b43251bb62d582df90be5a85b38ad0b4
child 310222 bcb4ebf6fface76931d93d089367c27ee108dd04
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbds
bugs1188186, 1293112, 1293113
milestone45.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 1188186 - Fix leak of FDs in |CreateTransport|. r=bds * Coverity's CIDs: 1293112 & 1293113
ipc/glue/Transport_posix.cpp
--- a/ipc/glue/Transport_posix.cpp
+++ b/ipc/glue/Transport_posix.cpp
@@ -4,16 +4,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 <unistd.h>
 
 #include <string>
 
+#include "base/eintr_wrapper.h"
+
 #include "chrome/common/child_process_info.h"
 
 #include "mozilla/ipc/Transport.h"
 #include "mozilla/ipc/FileDescriptor.h"
 
 using namespace std;
 
 using base::ProcessHandle;
@@ -36,16 +38,18 @@ CreateTransport(base::ProcessId aProcIdO
     return NS_ERROR_TRANSPORT_INIT;
   }
 
   // The Transport closes these fds when it goes out of scope, so we
   // dup them here
   fd1 = dup(fd1);
   fd2 = dup(fd2);
   if (fd1 < 0 || fd2 < 0) {
+    HANDLE_EINTR(close(fd1));
+    HANDLE_EINTR(close(fd2));
     return NS_ERROR_DUPLICATE_HANDLE;
   }
 
   aOne->mFd = base::FileDescriptor(fd1, true/*close after sending*/);
   aTwo->mFd = base::FileDescriptor(fd2, true/*close after sending*/);
   return NS_OK;
 }