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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Clear errno before calling strtol() in spell.c.
Date: 2025-03-08 16:25:16
Message-ID: E1tqwzE-001Rv5-21@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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 <jacob(dot)brazeal(at)gmail(dot)com>
Discussion: https://postgr.es/m/CA+COZaBhsq6EromFm+knMJfzK6nTpG23zJ+K2=nfUQQXcj_xcQ@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/da85544ae53f8eb86dcf0e50e3df2aa9068ca38a

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

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2025-03-08 19:26:36 pgsql: Don't convert to and from floats in pg_dump.
Previous Message Peter Geoghegan 2025-03-08 16:11:11 pgsql: Make parallel nbtree index scans use an LWLock.