From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 365aa50c; for ; Fri, 30 Jan 2015 12:32:46 -0500 (EST) Date: Fri, 30 Jan 2015 12:32:46 -0500 (EST) Message-Id: <1504504056425674909.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Delete the redundant tbl span flags, just inspect the actual X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Delete the redundant tbl span flags, just inspect the actual data where needed, which is less fragile. This fixes a subtle NULL pointer access to tp->tbl.cols: Due to a bug in the man(7) parser, the first span of a table can end up in a .TP head, in which case tblcalc() was never called. Found by jsg@ with afl. Modified Files: -------------- mdocml: man_term.c mandoc.h tbl.c tbl_data.c tbl_html.c tbl_term.c Revision Data ------------- Index: tbl_term.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/tbl_term.c,v retrieving revision 1.36 retrieving revision 1.37 diff -Ltbl_term.c -Ltbl_term.c -u -p -r1.36 -r1.37 --- tbl_term.c +++ tbl_term.c @@ -81,7 +81,7 @@ term_tbl(struct termp *tp, const struct * calculate the table widths and decimal positions. */ - if (sp->flags & TBL_SPAN_FIRST) { + if (tp->tbl.cols == NULL) { term_flushln(tp); tp->tbl.len = term_tbl_len; @@ -189,7 +189,7 @@ term_tbl(struct termp *tp, const struct * existing table configuration and set it to NULL. */ - if (sp->flags & TBL_SPAN_LAST) { + if (sp->next == NULL) { if (sp->opts->opts & (TBL_OPT_DBOX | TBL_OPT_BOX)) { tbl_hrule(tp, sp, 1); tp->skipvsp = 1; Index: man_term.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/man_term.c,v retrieving revision 1.166 retrieving revision 1.167 diff -Lman_term.c -Lman_term.c -u -p -r1.166 -r1.167 --- man_term.c +++ man_term.c @@ -949,7 +949,7 @@ print_man_node(DECL_ARGS) * Tables are preceded by a newline. Then process a * table line, which will cause line termination, */ - if (TBL_SPAN_FIRST & n->span->flags) + if (n->span->prev == NULL) term_newln(p); term_tbl(p, n->span); return; Index: tbl_data.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/tbl_data.c,v retrieving revision 1.38 retrieving revision 1.39 diff -Ltbl_data.c -Ltbl_data.c -u -p -r1.38 -r1.39 --- tbl_data.c +++ tbl_data.c @@ -173,7 +173,6 @@ newspan(struct tbl_node *tbl, int line, if (dp->prev == NULL) { tbl->first_span = dp; tbl->current_span = NULL; - dp->flags |= TBL_SPAN_FIRST; } else dp->prev->next = dp; tbl->last_span = dp; Index: tbl_html.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/tbl_html.c,v retrieving revision 1.15 retrieving revision 1.16 diff -Ltbl_html.c -Ltbl_html.c -u -p -r1.15 -r1.16 --- tbl_html.c +++ tbl_html.c @@ -54,7 +54,7 @@ html_tblopen(struct html *h, const struc struct roffcol *col; int ic; - if (sp->flags & TBL_SPAN_FIRST) { + if (h->tbl.cols == NULL) { h->tbl.len = html_tbl_len; h->tbl.slen = html_tbl_strlen; tblcalc(&h->tbl, sp, 0); @@ -132,7 +132,7 @@ print_tbl(struct html *h, const struct t h->flags &= ~HTML_NONOSPACE; - if (sp->flags & TBL_SPAN_LAST) { + if (sp->next == NULL) { assert(h->tbl.cols); free(h->tbl.cols); h->tbl.cols = NULL; Index: tbl.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/tbl.c,v retrieving revision 1.38 retrieving revision 1.39 diff -Ltbl.c -Ltbl.c -u -p -r1.38 -r1.39 --- tbl.c +++ tbl.c @@ -179,9 +179,5 @@ tbl_end(struct tbl_node **tblp) tbl->line, tbl->pos, NULL); return(0); } - - if (tbl->last_span != NULL) - tbl->last_span->flags |= TBL_SPAN_LAST; - return(1); } Index: mandoc.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v retrieving revision 1.193 retrieving revision 1.194 diff -Lmandoc.h -Lmandoc.h -u -p -r1.193 -r1.194 --- mandoc.h +++ mandoc.h @@ -285,9 +285,6 @@ struct tbl_span { struct tbl_span *prev; struct tbl_span *next; int line; /* parse line */ - int flags; -#define TBL_SPAN_FIRST (1 << 0) -#define TBL_SPAN_LAST (1 << 1) enum tbl_spant pos; }; -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv