diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-14 23:16:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-14 23:16:45 +0000 |
commit | 65a437fb801ab448b673ddd5061e5f6fcb3322ba (patch) | |
tree | a5e0a415f2e5942ddcab75f9ff3ca1e50c6a41ce /llvm/lib | |
parent | bbd8bd3257c412b9ec1afe6148ca95f548c818a0 (diff) | |
download | bcm5719-llvm-65a437fb801ab448b673ddd5061e5f6fcb3322ba.tar.gz bcm5719-llvm-65a437fb801ab448b673ddd5061e5f6fcb3322ba.zip |
don't forget to close a FD on an error condition, found by
cppcheck, PR6617. Patch by Ettl Martin!
llvm-svn: 98525
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/System/Unix/Program.inc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc index c10498a375a..b4cc875df8c 100644 --- a/llvm/lib/System/Unix/Program.inc +++ b/llvm/lib/System/Unix/Program.inc @@ -113,8 +113,9 @@ static bool RedirectIO(const Path *Path, int FD, std::string* ErrMsg) { } // Install it as the requested FD - if (-1 == dup2(InFD, FD)) { + if (dup2(InFD, FD) == -1) { MakeErrMsg(ErrMsg, "Cannot dup2"); + close(InFD); return true; } close(InFD); // Close the original FD |