From 75fcb4b560d40c7244831cba0bd49ff64f93a32d Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Wed, 28 Jan 2015 17:11:35 +0000 Subject: Avoid closing file descriptor twice * src/patch.c (main): Make sure we don't close() outfd after passing it on to fdopen(): the file descriptor might have been reused in the meantime. --- src/patch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/patch.c b/src/patch.c index cb4dbb2..7dafb54 100644 --- a/src/patch.c +++ b/src/patch.c @@ -339,6 +339,8 @@ main (int argc, char **argv) outstate.ofp = fdopen(outfd, binary_transput ? "wb" : "w"); if (! outstate.ofp) pfatal ("%s", TMPOUTNAME); + /* outstate.ofp now owns the file descriptor */ + outfd = -1; } /* find out where all the lines are */ -- cgit v1.2.1