Re: ParseTzFile doesn't FreeFile on error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: ParseTzFile doesn't FreeFile on error
Date: 2022-05-30 17:11:04
Message-ID: 3943931.1653930664@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> writes:
> The cause is ParseTzFile() returns leaving an open file descriptor
> unfreed in some error cases.
> This happens only in a special case when the errors are ignored, but
> in principle the file descriptor should be released before exiting the
> function.
> I'm not sure it's worth fixing but the attached fixes that.

I agree this is worth fixing, but adding all these gotos seems a bit
inelegant. What do you think of the attached version?

BTW, my first thought about it was "what if one of the callees throws
elog(ERROR), eg palloc out-of-memory"? But I think that's all right
since then we'll reach transaction abort cleanup, which won't whine
about open files. The problem is limited to the case where no error
gets thrown.

regards, tom lane

Attachment Content-Type Size
0002-Fix-ParseTzFile-to-call-FreeFile-on-error.patch text/x-diff 1.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2022-05-30 19:01:55 Re: Race conditions in 019_replslot_limit.pl
Previous Message Matthias van de Meent 2022-05-30 15:22:35 Re: Ignoring BRIN for HOT udpates seems broken