Thread
Commits
-
Clear errno before calling strtol() in spell.c.
- f1c1bafcdf76 13.21 landed
- da85544ae53f 14.18 landed
- e2921c0e9de3 15.13 landed
- 61513da08b16 16.9 landed
- 99c01aadf979 17.5 landed
- 7fb880102138 18.0 landed
-
Clear errno in spell.c
Jacob Brazeal <jacob.brazeal@gmail.com> — 2025-03-08T02:55:55Z
Hello! 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. Regards, Jacob
-
Re: Clear errno in spell.c
Tom Lane <tgl@sss.pgh.pa.us> — 2025-03-08T16:08:26Z
Jacob Brazeal <jacob.brazeal@gmail.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