aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-12-16 13:31:42 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2014-12-16 13:32:25 -0500
commit926da211a38e40f4aec78ccf8aab734bb9b69ba4 (patch)
treec559c1f78b1d66792b37b72c2d94d28d395a8ada
parentbca39b5788ae94a37e827e5b51c69cf2cf331d05 (diff)
downloadpostgresql-926da211a38e40f4aec78ccf8aab734bb9b69ba4.tar.gz
postgresql-926da211a38e40f4aec78ccf8aab734bb9b69ba4.zip
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.
-rw-r--r--contrib/pgbench/pgbench.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 456da705048..0384231083b 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -723,6 +723,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)