diff options
-rw-r--r-- | src/plain.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plain.cc b/src/plain.cc index 4da618e4..58fbdfb3 100644 --- a/src/plain.cc +++ b/src/plain.cc @@ -136,14 +136,17 @@ bool DilloPlain::PlainLinkReceiver::press (Widget *widget, int, int, int, int, void DilloPlain::addLine(char *Buf, uint_t BufSize) { int len; - char buf[128]; + char buf[129]; char *end = Buf + BufSize; if (BufSize > 0) { // Limit word length to avoid X11 coordinate // overflow with extremely long lines. - while ((len = a_Misc_expand_tabs(&Buf, end, buf, sizeof(buf)))) + while ((len = a_Misc_expand_tabs(&Buf, end, buf, sizeof(buf) - 1))) { + assert (len < sizeof(buf)); + buf[len] = '\0'; DW2TB(dw)->addText(buf, len, widgetStyle); + } } else { // Add dummy word for empty lines - otherwise the parbreak is ignored. DW2TB(dw)->addText("", 0, widgetStyle); |