From 5b2c8f04a7cdf161f09ed45c235f0eebf3d88f0d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 16 Dec 2014 13:31:42 -0500 Subject: [PATCH] Fix file descriptor leak after failure of a \setshell command in pgbench. If the called command fails to return data, runShellCommand forgot to pclose() the pipe before returning. This is fairly harmless in the current code, because pgbench would then abandon further processing of that client thread; so no more than nclients descriptors could be leaked this way. But it's not hard to imagine future improvements whereby that wouldn't be true. In any case, it's sloppy coding, so patch all branches. Found by Coverity. --- contrib/pgbench/pgbench.c | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 5d7ad96cff..d87e75c770 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -749,6 +749,7 @@ runShellCommand(CState *st, char *variable, char **argv, int argc) { if (!timer_exceeded) fprintf(stderr, "%s: cannot read the result\n", argv[0]); + (void) pclose(fp); return false; } if (pclose(fp) < 0) -- 2.40.0