Re: pgsql: Fix inconsequential FILE pointer leakage - Mailing list pgsql-committers

From Alvaro Herrera
Subject Re: pgsql: Fix inconsequential FILE pointer leakage
Date
Msg-id 1292530585-sup-7453@alvh.no-ip.org
Whole thread Raw
In response to Re: pgsql: Fix inconsequential FILE pointer leakage  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-committers
Excerpts from Tom Lane's message of jue dic 16 17:00:43 -0300 2010:

> --- 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.

Gah, yes, sorry.  Fixed.

--
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: Avoid clobbering errno, per comment from Tom.
Next
From: Tom Lane
Date:
Subject: pgsql: Remove optreset from src/port/ implementations of getopt and get