Clear errno before calling strtol() in spell.c.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 8 Mar 2025 16:24:22 +0000 (11:24 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 8 Mar 2025 16:24:52 +0000 (11:24 -0500)
commite2921c0e9de3c153b9d75d1fcf219afce42f64c7
tree2824f0b92dd3038ece69fa7650d3c5616965e258
parentbc6a81ac3a8346c9f3cb5fc6f714977127aa2f31
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.brazeal@gmail.com>
Discussion: http://postgr.es/m/CA+COZaBhsq6EromFm+knMJfzK6nTpG23zJ+K2=nfUQQXcj_xcQ@mail.gmail.com
Backpatch-through: 13
src/backend/tsearch/spell.c