From 244d91e692e1b324ecf144eb153c3ded672b57d1 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 8 Jul 2017 13:43:15 +0000 Subject: Correctly handle horizontal spans at the beginning of rows, fixing an assertion failure found by jsg@ with afl(1). While here, also drop printing of whitespace in tbl_data() which makes no difference because column positioning code in term_tbl() already takes care of that. --- tbl_term.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tbl_term.c b/tbl_term.c index 8fc4bc8c..1d4b0389 100644 --- a/tbl_term.c +++ b/tbl_term.c @@ -170,7 +170,8 @@ term_tbl(struct termp *tp, const struct tbl_span *sp) if (dp == NULL) continue; spans = dp->spans; - dp = dp->next; + if (ic || sp->layout->first->pos != TBL_CELL_SPAN) + dp = dp->next; } /* Set up a column for a right vertical frame. */ @@ -204,7 +205,8 @@ term_tbl(struct termp *tp, const struct tbl_span *sp) if (dp == NULL) continue; spans = dp->spans; - dp = dp->next; + if (cp->pos != TBL_CELL_SPAN) + dp = dp->next; } break; } @@ -304,7 +306,9 @@ term_tbl(struct termp *tp, const struct tbl_span *sp) } if (dp != NULL) { spans = dp->spans; - dp = dp->next; + if (ic || sp->layout->first->pos + != TBL_CELL_SPAN) + dp = dp->next; } /* @@ -514,14 +518,11 @@ tbl_data(struct termp *tp, const struct tbl_opts *opts, break; } - if (dp == NULL) { - tbl_char(tp, ASCII_NBRSP, col->width); + if (dp == NULL) return; - } switch (dp->pos) { case TBL_DATA_NONE: - tbl_char(tp, ASCII_NBRSP, col->width); return; case TBL_DATA_HORIZ: case TBL_DATA_NHORIZ: @@ -546,7 +547,7 @@ tbl_data(struct termp *tp, const struct tbl_opts *opts, tbl_number(tp, opts, dp, col); break; case TBL_CELL_DOWN: - tbl_char(tp, ASCII_NBRSP, col->width); + case TBL_CELL_SPAN: break; default: abort(); -- cgit