postgres.git / summary / log / commit / refs

commit    926da211a38e40f4aec78ccf8aab734bb9b69ba4
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Tue Dec 16 18:31:42 2014 +0000
First released in: 9.5.0, 9.0.19, 9.1.15, 9.2.10, 9.3.6, 9.4.1

    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 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) [parent: bca39b5788ae]