diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-04-04 15:45:12 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-04-04 15:45:12 +0000 |
commit | a8559d4053327df0d5b00c41247ee89fd1c4dbe3 (patch) | |
tree | d2cf4ff84c3d270826d3aee457fefa142d126d3d /mdoc_html.c | |
parent | a97a36dac2b13152973ff3eec896b68c0e2512dc (diff) | |
download | mandoc-a8559d4053327df0d5b00c41247ee89fd1c4dbe3.tar.gz |
Fix possible segfaults in `Lk' -T[x]html handler, which made some
assumptions about its children. Also remove superfluous reassignment to
local variable.
Diffstat (limited to 'mdoc_html.c')
-rw-r--r-- | mdoc_html.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/mdoc_html.c b/mdoc_html.c index 8812c02a..10c9a942 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -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); } |