Mercurial > vim
changeset 15166:694594a0d25d v8.1.0593
patch 8.1.0593: illegal memory access in libvterm test
commit https://github.com/vim/vim/commit/37e3edce200c5a0ae8f81ca729b18d75477d2725
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 15 14:49:34 2018 +0100
patch 8.1.0593: illegal memory access in libvterm test
Problem: Illegal memory access in libvterm test.
Solution: Fix off-by-one error.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 15 Dec 2018 15:00:07 +0100 |
parents | 2bd7ea917861 |
children | e958bbe5bf1b |
files | src/libvterm/Makefile src/libvterm/src/vterm.c src/libvterm/t/run-test.pl src/version.c |
diffstat | 4 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/libvterm/Makefile +++ b/src/libvterm/Makefile @@ -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)
--- a/src/libvterm/src/vterm.c +++ b/src/libvterm/src/vterm.c @@ -169,9 +169,9 @@ INTERNAL void vterm_push_output_vsprintf #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) {
--- a/src/libvterm/t/run-test.pl +++ b/src/libvterm/t/run-test.pl @@ -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 - $!"; }