diff options
author | Joerg Sonnenberger <joerg@netbsd.org> | 2011-11-18 17:04:06 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@netbsd.org> | 2011-11-18 17:04:06 +0000 |
commit | 31bff0d8373809f1134dded2e446815d7cb4d8ac (patch) | |
tree | 0a92533840ca122d0d38f4b248d035986ba2a4ed | |
parent | 6305e2fccbe1b3704fb25243dd15a78ad17b36b1 (diff) | |
download | mandoc-31bff0d8373809f1134dded2e446815d7cb4d8ac.tar.gz |
Don't crash if the date can't be extracted. Don't depend on snprintf
handling NULL strings.
-rw-r--r-- | man_term.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -969,8 +969,9 @@ print_man_foot(struct termp *p, const void *arg) term_vspace(p); term_vspace(p); term_vspace(p); - snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec); - datelen = term_strlen(p, meta->date); + snprintf(title, BUFSIZ, "%s(%s)", meta->title ? meta->title : "", + meta->msec ? meta->msec : ""); + datelen = term_strlen(p, meta->date ? meta->date : ""); p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; p->offset = 0; @@ -986,7 +987,7 @@ print_man_foot(struct termp *p, const void *arg) if (p->offset + datelen >= p->rmargin) p->rmargin = p->offset + datelen; - term_word(p, meta->date); + term_word(p, meta->date ? meta->date : ""); term_flushln(p); p->flags &= ~TERMP_NOBREAK; @@ -1023,7 +1024,8 @@ print_man_head(struct termp *p, const void *arg) strlcpy(buf, m->vol, BUFSIZ); buflen = term_strlen(p, buf); - snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec); + snprintf(title, BUFSIZ, "%s(%s)", m->title ? m->title : "", + m->msec ? m->msec : ""); titlen = term_strlen(p, title); p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; |