summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-03-29 21:27:06 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-03-29 21:27:06 +0000
commit4e02ff5bbc7d9dfafc781a1534b153cae8cea86c (patch)
tree2f72c80b7c50276f77e992c16fa1cbc16d799dab
parent4af7601e56b07fe1eb2c110fd7633ef66197ae30 (diff)
downloadmandoc-4e02ff5bbc7d9dfafc781a1534b153cae8cea86c.tar.gz
Set the maximum column index in a tbl(7) to the maximum *right* edge
of any cell span, not to the maximum *left* edge, which may be smaller if the last column of the table is only reached by horizontal spans, but not by any regular cell in any row of the table. Otherwise, the algorithm calculating column widths accessed memomy after the end of the colwidth[] array, while it was trying to handle the rightmost column(s). Crash reported by Jason Thorpe <thorpej at NetBSD> via https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=54069 and via Thomas Klausner (wiz@). Christos@ Zoulas sent a (correct, but slightly confusing) patch. The patch i'm committing here is easier to understand.
-rw-r--r--out.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/out.c b/out.c
index a7b70635..58310d3b 100644
--- a/out.c
+++ b/out.c
@@ -149,7 +149,7 @@ tblcalc(struct rofftbl *tbl, const struct tbl_span *sp_first,
gp = &first_group;
for (dp = sp->first; dp != NULL; dp = dp->next) {
icol = dp->layout->col;
- while (icol > maxcol)
+ while (maxcol < icol + dp->hspans)
tbl->cols[++maxcol].spacing = SIZE_MAX;
col = tbl->cols + icol;
col->flags |= dp->layout->flags;