]> granicus.if.org Git - vim/commitdiff
patch 8.1.0593: illegal memory access in libvterm test v8.1.0593
authorBram Moolenaar <Bram@vim.org>
Sat, 15 Dec 2018 13:49:34 +0000 (14:49 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 15 Dec 2018 13:49:34 +0000 (14:49 +0100)
Problem:    Illegal memory access in libvterm test.
Solution:   Fix off-by-one error.

src/libvterm/Makefile
src/libvterm/src/vterm.c
src/libvterm/t/run-test.pl
src/version.c

index 6eacab766145d3dba4cfde2c9f7aa063c2dda541..179ee10d7502a000a9702d3a0a210b0e4c018534 100644 (file)
@@ -52,6 +52,9 @@ INCDIR=$(PREFIX)/include
 MANDIR=$(PREFIX)/share/man
 MAN3DIR=$(MANDIR)/man3
 
+# Uncomment to check for memory access errors with valgrind.
+# VALGRIND=1
+
 all: $(LIBRARY) $(BINFILES)
 
 $(LIBRARY): $(OBJECTS)
index 28613b9b06f9c829a6795717c2dec49d12f09023..9025da4449b1e66533a41fa015f43ac1bc848938 100644 (file)
@@ -169,9 +169,9 @@ INTERNAL void vterm_push_output_vsprintf(VTerm *vt, const char *format, va_list
 #else
   written = vsprintf(buffer, format, args);
 
-  if(written >= (int)(vt->outbuffer_len - vt->outbuffer_cur)) {
+  if(written >= (int)(vt->outbuffer_len - vt->outbuffer_cur - 1)) {
     /* output was truncated */
-    written = vt->outbuffer_len - vt->outbuffer_cur;
+    written = vt->outbuffer_len - vt->outbuffer_cur - 1;
   }
   if (written > 0)
   {
index 4ef0f26d47b63a11e0afc4cf3f6465157ea99b7d..12e11801b63ff6a92357ee604460577c64620626 100644 (file)
@@ -16,7 +16,7 @@ my ( $hin, $hout, $hpid );
 {
    local $ENV{LD_LIBRARY_PATH} = ".libs";
    my @command = "t/.libs/harness";
-   unshift @command, "valgrind", "--quiet", "--error-exitcode=126" if $VALGRIND;
+   unshift @command, "valgrind", "--tool=memcheck", "--leak-check=yes", "--num-callers=25", "--log-file=valgrind.out", "--error-exitcode=126" if $VALGRIND;
 
    $hpid = open2 $hout, $hin, @command or die "Cannot open2 harness - $!";
 }
index 4e79d28a29d2ccfd821a086af71bdb1d6512730a..b1de233f9fa19f4d39f4707d015fc0abb2984236 100644 (file)
@@ -799,6 +799,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    593,
 /**/
     592,
 /**/