diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2012-12-10 21:51:59 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2012-12-10 21:51:59 +0100 |
commit | dec63a3f335a4997ef9d9f0ab3ba059ad2c5aa5c (patch) | |
tree | 135d80b2aee46c1908f3590f08698b906cda27c9 | |
parent | e116ca044a68ed209342fc3c486cca4ad23064e1 (diff) |
fix valgrind errors with plain files
-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); |