Subject: pgsql: Clear errno before calling strtol() in spell.c.

From: Tom Lane <[email-masked]>
Date: Sat, 08 Mar 2025 16:25:16 +0000

Clear errno before calling strtol() in spell.c.

Per POSIX, a caller of strtol() that wishes to check for errors must
set errno to 0 beforehand.  Several places in spell.c neglected that,
so that they risked delivering a false overflow error in case errno
had been ERANGE already.  Given the lack of field reports, this case
may be unreachable at present --- but it's surely trouble waiting to
happen, so fix it.

Author: Jacob Brazeal <[email-masked]>
Discussion: https://postgr.es/m/CA+COZaBhsq6EromFm+knMJfzK6nTpG23zJ+K2=[email-masked]
Backpatch-through: 13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7fb880102138e45f58bf626cb2a4599bade8b172

Modified Files
--------------
src/backend/tsearch/spell.c | 4 ++++
1 file changed, 4 insertions(+)