CVSROOT: /cvs
Module name: src
Changes by: [email protected] 2026/09/08 15:10:21
Modified files:
usr.bin/mandoc : read.c
Log message:
Do not call the high-level mdoc(7) or man(7) parser cleanup
before the low-level roff(7) parser cleanup;
instead, clean up in the opposite order.
>From a perspective of traditional roff(7) systems, the existing order
might seem intuitive: a traditional system needs the low-level roff(7)
infrastructure in an operational state for doing anything with
high-level macros.
However, in mandoc(1), the architecture is built up in the opposite way.
The mdoc(7) and man(7) parsers provide the foundational tree structure,
and the roff(7) parser only serves auxiliary functions that need the
mdoc(7) and man(7) infrastructure in an operational state.
If the .TE macro ending a tbl(7) was missing before the end of the input
file, this logic bug caused man_endparse() to reset the parse point to the
root of the syntax tree, only for roff_endtbl() called from roff_endparse()
then expecting the parse point to still point to the ROFFT_TBL node,
resulting in a NULL pointer access in roff_endtbl().
The present logic correction also fixes a segfault found with a test file
designed by Hippolyte d'Oncieu de la Batie <[email protected]>,
forwarded to me by espie@.