aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-14 23:16:45 +0000
committerChris Lattner <sabre@nondot.org>2010-03-14 23:16:45 +0000
commitcdff5f77872bf57ed9f9b347e49ac08b9e87800e (patch)
tree338469efd7001e6e18566c35fbb152e3734ee352
parent82c3dc63474b3e25bf70db31b2e1d71903485b81 (diff)
downloadexternal_llvm-cdff5f77872bf57ed9f9b347e49ac08b9e87800e.zip
external_llvm-cdff5f77872bf57ed9f9b347e49ac08b9e87800e.tar.gz
external_llvm-cdff5f77872bf57ed9f9b347e49ac08b9e87800e.tar.bz2
don't forget to close a FD on an error condition, found by
cppcheck, PR6617. Patch by Ettl Martin! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98525 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/System/Unix/Program.inc3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc
index c10498a..b4cc875 100644
--- a/lib/System/Unix/Program.inc
+++ b/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