diff options
author | 2011-04-04 15:45:12 +0000 | |
---|---|---|
committer | 2011-04-04 15:45:12 +0000 | |
commit | 3365da8c7b74a96d461c59ad107018620778ab2e (patch) | |
tree | 917b325544333a7b810275f521c1027ac24ea078 | |
parent | 6a8b10b9828abaa30a401704794769bfe61d4e5d (diff) | |
download | mandoc-3365da8c7b74a96d461c59ad107018620778ab2e.tar.gz mandoc-3365da8c7b74a96d461c59ad107018620778ab2e.tar.zst mandoc-3365da8c7b74a96d461c59ad107018620778ab2e.zip |
Fix possible segfaults in `Lk' -T[x]html handler, which made some
assumptions about its children. Also remove superfluous reassignment to
local variable.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | mdoc_html.c | 22 |
2 files changed, 13 insertions, 11 deletions
@@ -317,7 +317,7 @@ mandoc: $(MANDOC_OBJS) libmandoc.a # You'll need -ldb for Linux. mandoc-db: $(MANDOCDB_OBJS) libmandoc.a - $(CC) -o $@ $(MANDOCDB_OBJS) libmandoc.a + $(CC) -o $@ $(MANDOCDB_OBJS) libmandoc.a -ldb llib-lmandoc.ln: $(MANDOC_LNS) $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS) diff --git a/mdoc_html.c b/mdoc_html.c index efe023ef..128578d3 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.157 2011/04/04 15:41:05 kristaps Exp $ */ +/* $Id: mdoc_html.c,v 1.158 2011/04/04 15:45:12 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -1603,20 +1603,22 @@ mdoc_sp_pre(MDOC_ARGS) static int mdoc_lk_pre(MDOC_ARGS) { - const struct mdoc_node *nn; - struct htmlpair tag[2]; + struct htmlpair tag[2]; + + if (NULL == (n = n->child)) + return(0); - nn = n->child; + assert(MDOC_TEXT == n->type); PAIR_CLASS_INIT(&tag[0], "link-ext"); - PAIR_HREF_INIT(&tag[1], nn->string); - print_otag(h, TAG_A, 2, tag); + PAIR_HREF_INIT(&tag[1], n->string); - if (NULL == nn || NULL == nn->next) - return(1); + print_otag(h, TAG_A, 2, tag); - for (nn = nn->next; nn; nn = nn->next) - print_text(h, nn->string); + for (n = n->next; n; n = n->next) { + assert(MDOC_TEXT == n->type); + print_text(h, n->string); + } return(0); } |