diff options
author | mseaborn <mseaborn@chromium.org> | 2015-12-01 09:11:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-01 17:12:17 +0000 |
commit | c491cab4a03193764236338b3acfccff5884d3bc (patch) | |
tree | 88b88f4541af7840f16ea7083cfa5b278c4a0d6c | |
parent | 7a7643ee8652ddab8503c57fe0ff1af174ea235b (diff) | |
download | chromium_src-c491cab4a03193764236338b3acfccff5884d3bc.zip chromium_src-c491cab4a03193764236338b3acfccff5884d3bc.tar.gz chromium_src-c491cab4a03193764236338b3acfccff5884d3bc.tar.bz2 |
NaCl: Fix a file descriptor leak on Unix
Before this change, the renderer process leaks a file descriptor every
time a PNaCl translator process is launched or a (P)NaCl process runs
without calling the ppapi_start() API.
There was no leak on Windows, because client-side IPC::ChannelHandles
fill out the "name" field rather than the "pipe.handle" field.
BUG=302078
TEST=Run an invalid pexe repeatedly and manually inspect /proc/PID/fd
of the renderer process.
Review URL: https://codereview.chromium.org/1473513005
Cr-Commit-Position: refs/heads/master@{#362440}
-rw-r--r-- | components/nacl/renderer/ppb_nacl_private_impl.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc index dfc7af8..07d20e2 100644 --- a/components/nacl/renderer/ppb_nacl_private_impl.cc +++ b/components/nacl/renderer/ppb_nacl_private_impl.cc @@ -66,6 +66,10 @@ #include "third_party/WebKit/public/web/WebSecurityOrigin.h" #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" +#if defined(OS_WIN) +#include "base/win/scoped_handle.h" +#endif + namespace nacl { namespace { @@ -121,6 +125,17 @@ class NaClPluginInstance { public: NaClPluginInstance(PP_Instance instance): nexe_load_manager(instance), pexe_size(0) {} + ~NaClPluginInstance() { + // Make sure that we do not leak a file descriptor if the NaCl loader + // process never called ppapi_start() to initialize PPAPI. + if (instance_info) { +#if defined(OS_WIN) + base::win::ScopedHandle closer(instance_info->channel_handle.pipe.handle); +#else + base::ScopedFD closer(instance_info->channel_handle.socket.fd); +#endif + } + } NexeLoadManager nexe_load_manager; scoped_ptr<JsonManifest> json_manifest; |