Re: Clear errno in spell.c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Clear errno in spell.c
Date: 2025-03-08 16:08:26
Message-ID: 1299648.1741450106@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com> writes:
> Several times in spell.c, we call strtol and then check the errno, but we
> do not clear out errno = 0 before strtol, as is customary (and done
> everywhere else in the codebase that I could find.) This could
> hypothetically lead to us incorrectly logging an error.

Yeah. Looking around, we seem quite haphazard about whether we
check errno at all after strtol and siblings. But certainly, doing
so without clearing it beforehand is a Bad Idea.

It's surprising that we've not heard reports of problems here. Maybe
the I/O involved in reading the dictionary file we're parsing clears
errno and then never sets it to ERANGE? But I didn't see an obvious
place where it cleared errno. Anyway, even if this isn't a live bug
it's surely a latent one, so I'll push your patch.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2025-03-08 16:15:23 Re: Special-case executor expression steps for common combinations
Previous Message Robert Treat 2025-03-08 15:56:20 Re: Statistics Import and Export