From 0fdaab995ed95250b13058a717d5bc562e1834c8 Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 2 Jul 2015 20:15:41 +0300 Subject: mark: Fix valgrind error in mark.c Caused by using memcpy for assigning one structure to another. --- src/nvim/mark.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/mark.c b/src/nvim/mark.c index ce44149ffa..6ac4b1de9c 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -1117,10 +1117,17 @@ static void cleanup_jumplist(void) && curwin->w_jumplist[i].fmark.mark.lnum == curwin->w_jumplist[from].fmark.mark.lnum) break; - if (i >= curwin->w_jumplistlen) /* no duplicate */ - curwin->w_jumplist[to++] = curwin->w_jumplist[from]; - else + if (i >= curwin->w_jumplistlen) { // no duplicate + if (to != from) { + // Not using curwin->w_jumplist[to++] = curwin->w_jumplist[from] because + // this way valgrind complains about overlapping source and destination + // in memcpy() call. (clang-3.6.0, debug build with -DEXITFREE). + curwin->w_jumplist[to] = curwin->w_jumplist[from]; + } + to++; + } else { xfree(curwin->w_jumplist[from].fname); + } } if (curwin->w_jumplistidx == curwin->w_jumplistlen) curwin->w_jumplistidx = to; -- cgit