diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 20:19:10 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 20:19:10 +0000 |
commit | 5ec89fa2cffd6582b311b1861e4fbd8af71bc5ae (patch) | |
tree | 164a003f7d5fa5423aa9c2e34b86bb0055781b0c /base | |
parent | c714a16415946fe384b4ba341fc67697b9e79af3 (diff) | |
download | chromium_src-5ec89fa2cffd6582b311b1861e4fbd8af71bc5ae.zip chromium_src-5ec89fa2cffd6582b311b1861e4fbd8af71bc5ae.tar.gz chromium_src-5ec89fa2cffd6582b311b1861e4fbd8af71bc5ae.tar.bz2 |
Ensures we don't leak handles in ProcessUtil::GetAppOutput.
TEST=Run base_unit_tests
BUG=None
Review URL: http://codereview.chromium.org/93030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14235 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/process_util_win.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/base/process_util_win.cc b/base/process_util_win.cc index 3664c5c..13fec9a 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -203,6 +203,10 @@ bool GetAppOutput(const std::wstring& cmd_line, std::string* output) { return false; } + // Ensure we don't leak the handles. + ScopedHandle scoped_out_read(out_read); + ScopedHandle scoped_out_write(out_write); + // Ensure the read handle to the pipe for STDOUT is not inherited. if (!SetHandleInformation(out_read, HANDLE_FLAG_INHERIT, 0)) { NOTREACHED() << "Failed to disabled pipe inheritance"; @@ -231,10 +235,9 @@ bool GetAppOutput(const std::wstring& cmd_line, std::string* output) { // We don't need the thread handle, close it now. CloseHandle(proc_info.hThread); - if (!CloseHandle(out_write)) { - NOTREACHED() << "Failed to close std out write pipe."; - return false; - } + // Close our writing end of pipe now. Otherwise later read would not be able + // to detect end of child's output. + scoped_out_write.Close(); // Read output from the child process's pipe for STDOUT const int kBufferSize = 1024; @@ -252,9 +255,6 @@ bool GetAppOutput(const std::wstring& cmd_line, std::string* output) { WaitForSingleObject(proc_info.hProcess, INFINITE); CloseHandle(proc_info.hProcess); - BOOL r = CloseHandle(out_read); - DCHECK(r) << "Failed to close std out read pipe."; - return true; } |