From 31bff0d8373809f1134dded2e446815d7cb4d8ac Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Fri, 18 Nov 2011 17:04:06 +0000 Subject: Don't crash if the date can't be extracted. Don't depend on snprintf handling NULL strings. --- man_term.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/man_term.c b/man_term.c index bafd55e4..caef1e00 100644 --- a/man_term.c +++ b/man_term.c @@ -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; -- cgit