Hi,

Raf Czlonka wrote on Thu, Mar 16, 2017 at 10:56:23PM +0000:

> While looking at several manual pages on man.openbsd.org,

Thanks for testing, ...

> I've noticed that roff(7) man page does not render properly
> in its entirety,

 ... and for reporting.

> No idea what might be causing the issue, I'm afraid.

And thanks to Martin Natano for telling me what caused this.

Fixed by the commit below.

While the print_otag "i" (id) request intentionally accepts NULL
such that the same call can write the tag with or without id,
the <a> tag must not be written at all if we don't have an id.

Yours,
  Ingo


Log Message:
-----------
Fix regression in mdoc_html.c 1.275, man_html 1.134:
For .Sh, .Ss, .SH, .SS, only write selflink if an id could be constructed.
Crash reported by Raf Czlonka <rczlonka at gmail dot com>,
analysis of root cause by natano@

Modified Files:
--------------
    mdocml:
        man_html.c
        mdoc_html.c

Revision Data
-------------
Index: man_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_html.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -Lman_html.c -Lman_html.c -u -p -r1.134 -r1.135
--- man_html.c
+++ man_html.c
@@ -440,7 +440,8 @@ man_SH_pre(MAN_ARGS)
        if (n->type == ROFFT_HEAD) {
                id = html_make_id(n);
                print_otag(h, TAG_H1, "cTi", "Sh", id);
-               print_otag(h, TAG_A, "chR", "selflink", id);
+               if (id != NULL)
+                       print_otag(h, TAG_A, "chR", "selflink", id);
                free(id);
        }
        return 1;
@@ -509,7 +510,8 @@ man_SS_pre(MAN_ARGS)
        if (n->type == ROFFT_HEAD) {
                id = html_make_id(n);
                print_otag(h, TAG_H2, "cTi", "Ss", id);
-               print_otag(h, TAG_A, "chR", "selflink", id);
+               if (id != NULL)
+                       print_otag(h, TAG_A, "chR", "selflink", id);
                free(id);
        }
        return 1;
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_html.c,v
retrieving revision 1.277
retrieving revision 1.278
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.277 -r1.278
--- mdoc_html.c
+++ mdoc_html.c
@@ -501,7 +501,8 @@ mdoc_sh_pre(MDOC_ARGS)
        case ROFFT_HEAD:
                id = html_make_id(n);
                print_otag(h, TAG_H1, "cTi", "Sh", id);
-               print_otag(h, TAG_A, "chR", "selflink", id);
+               if (id != NULL)
+                       print_otag(h, TAG_A, "chR", "selflink", id);
                free(id);
                break;
        case ROFFT_BODY:
@@ -524,7 +525,8 @@ mdoc_ss_pre(MDOC_ARGS)
 
        id = html_make_id(n);
        print_otag(h, TAG_H2, "cTi", "Ss", id);
-       print_otag(h, TAG_A, "chR", "selflink", id);
+       if (id != NULL)
+               print_otag(h, TAG_A, "chR", "selflink", id);
        free(id);
        return 1;
 }

Reply via email to