Valgrind memory checker finds the following error in vim-7.1.156:

==6314== Source and destination overlap in strcpy(0x4B81DD0, 0x4B81DD1)
==6314==    at 0x40245D2: strcpy (mc_replace_strmem.c:106)
==6314==    by 0x80986CA: do_sub (ex_cmds.c:4888)
==6314==    by 0x80A50EA: do_one_cmd (ex_docmd.c:2621)
==6314==    by 0x80A293A: do_cmdline (ex_docmd.c:1099)
==6314==    by 0x8128CA6: nv_colon (normal.c:5175)
==6314==    by 0x812226A: normal_cmd (normal.c:1148)
==6314==    by 0x80E5245: main_loop (main.c:1181)
==6314==    by 0x80E4D95: main (main.c:940)

I can reproduce it when using <CTRL-M> in the substituted string.

For example:

  $ echo foo > test.txt
  $ valgrind ./vim -u NONE -U NONE -c '%s/^/^Ma' test.txt 2>vg.log

(where ^M can be typed with <CTRL-V><CTRL-M>)

I attach a simple patch.

I am using vim on Linux, built without optimizations -O0.

-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Index: ex_cmds.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/ex_cmds.c,v
retrieving revision 1.97
diff -c -r1.97 ex_cmds.c
*** ex_cmds.c	8 Nov 2007 19:48:52 -0000	1.97
--- ex_cmds.c	17 Nov 2007 06:30:58 -0000
***************
*** 4885,4891 ****
  			    ++line2;
  			    /* move the cursor to the new line, like Vi */
  			    ++curwin->w_cursor.lnum;
! 			    STRCPY(new_start, p1 + 1);	/* copy the rest */
  			    p1 = new_start - 1;
  			}
  		    }
--- 4885,4892 ----
  			    ++line2;
  			    /* move the cursor to the new line, like Vi */
  			    ++curwin->w_cursor.lnum;
! 			    /* copy the rest */
! 			    mch_memmove(new_start, p1 + 1, STRLEN(p1 + 1) + 1);
  			    p1 = new_start - 1;
  			}
  		    }

Raspunde prin e-mail lui