]> granicus.if.org Git - sudo/commitdiff
Print a trailing newline in lbuf_print() when there is not enough
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 4 Sep 2012 14:42:09 +0000 (10:42 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 4 Sep 2012 14:42:09 +0000 (10:42 -0400)
space to do word wrapping and the lbuf does not end with a newline.

common/lbuf.c

index 4618b94b5b3bd047fb418219ef97255c9c91ef13..3b20323fc43608d7afbfd81293ed14f76cc52699 100644 (file)
@@ -247,8 +247,12 @@ lbuf_print(struct lbuf *lbuf)
     /* For very small widths just give up... */
     len = lbuf->continuation ? strlen(lbuf->continuation) : 0;
     if (lbuf->cols <= lbuf->indent + len + 20) {
-       lbuf->buf[lbuf->len] = '\0';
-       lbuf->output(lbuf->buf);
+       if (lbuf->len > 0) {
+           lbuf->buf[lbuf->len] = '\0';
+           lbuf->output(lbuf->buf);
+           if (lbuf->buf[lbuf->len - 1] != '\n')
+               lbuf->output("\n");
+       }
        goto done;
     }