aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-10-14 18:18:05 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-10-14 18:18:05 +0000
commit191186556e8df468bec99ae47cd09817e9d288a0 (patch)
tree33cbd2f6bff7a270da2c757a7206d0962c027843
parentf812f5cbb9c18b510bd7cd7f3c942b4356075a9e (diff)
downloadmandoc-191186556e8df468bec99ae47cd09817e9d288a0.tar.gz
mandoc-191186556e8df468bec99ae47cd09817e9d288a0.tar.zst
mandoc-191186556e8df468bec99ae47cd09817e9d288a0.zip
even if a table has zero columns, do not segfault in the formatter;
bug reported by bentley@
-rw-r--r--out.c4
-rw-r--r--tbl_term.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/out.c b/out.c
index 93cc9658..5b08a09a 100644
--- a/out.c
+++ b/out.c
@@ -1,4 +1,4 @@
-/* $Id: out.c,v 1.52 2014/10/14 02:16:06 schwarze Exp $ */
+/* $Id: out.c,v 1.53 2014/10/14 18:18:05 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -158,7 +158,7 @@ tblcalc(struct rofftbl *tbl, const struct tbl_span *sp,
tbl->cols = mandoc_calloc((size_t)sp->opts->cols,
sizeof(struct roffcol));
- for (maxcol = 0; sp; sp = sp->next) {
+ for (maxcol = -1; sp; sp = sp->next) {
if (TBL_SPAN_DATA != sp->pos)
continue;
spans = 1;
diff --git a/tbl_term.c b/tbl_term.c
index 6a733506..0275b1a2 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_term.c,v 1.30 2014/10/14 02:16:06 schwarze Exp $ */
+/* $Id: tbl_term.c,v 1.31 2014/10/14 18:18:05 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -107,7 +107,7 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
/* Vertical frame at the start of each row. */
if ((TBL_OPT_BOX | TBL_OPT_DBOX) & sp->opts->opts ||
- sp->head->vert)
+ (sp->head != NULL && sp->head->vert))
term_word(tp, TBL_SPAN_HORIZ == sp->pos ||
TBL_SPAN_DHORIZ == sp->pos ? "+" : "|");