Skip site navigation (1) Skip section navigation (2)

Re: pgsql: Fix inconsequential FILE pointer leakage

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Fix inconsequential FILE pointer leakage
Date: 2010-12-16 20:00:43
Message-ID: 11112.1292529643@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-committers
Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:

--- a/src/port/exec.c
+++ b/src/port/exec.c
@@ -357,6 +357,7 @@ pipe_read_line(char *cmd, char *line, int maxsize)
 
    if (fgets(line, maxsize, pgver) == NULL)
    {
+       pclose(pgver);      /* no error checking */
        perror("fgets failure");
        return NULL;
    }

Doesn't this risk having pclose trash the errno setting that perror is
going to print?  If you must do this, please do it in the other order.

			regards, tom lane

In response to

Responses

pgsql-committers by date

Next:From: Alvaro HerreraDate: 2010-12-16 20:16:30
Subject: pgsql: Avoid clobbering errno, per comment from Tom.
Previous:From: Alvaro HerreraDate: 2010-12-16 19:47:25
Subject: pgsql: Fix inconsequential FILE pointer leakage

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group