From dec63a3f335a4997ef9d9f0ab3ba059ad2c5aa5c Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 10 Dec 2012 21:51:59 +0100 Subject: fix valgrind errors with plain files --- src/plain.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/plain.cc') 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); -- cgit v1.2.3