Hi
Using Vim-7.3.475, I can reproduce a memory leak using
the ':rv!' command when reading dictionary or list global
variables i.e. with 'viminfo' containing ! (:help viminfo-!).
Steps to reproduce:
$ cat > leak.vim <<EOF
set nocp
set viminfo+=!
let FOO=[]
let BAR={'bar':1}
wv! /tmp/foobar
rv! /tmp/foobar
rv! /tmp/foobar
rv! /tmp/foobar
EOF
$ valgrind --leak-check=yes --log-file=vg.log vim -u NONE -S leak.vim
Then exit Vim with :q and notice that log file vg.log contains the
following leak:
==17285== 96 bytes in 6 blocks are definitely lost in loss record 70 of 95
==17285== at 0x4C241C3: malloc (vg_replace_malloc.c:195)
==17285== by 0x4D8AF9: lalloc (misc2.c:928)
==17285== by 0x4D8A18: alloc (misc2.c:827)
==17285== by 0x432D8D: eval_expr (eval.c:1548)
==17285== by 0x4542A9: read_viminfo_varlist (eval.c:22964)
==17285== by 0x458BC6: read_viminfo_up_to_marks (ex_cmds.c:2134)
==17285== by 0x4589FE: do_viminfo (ex_cmds.c:2053)
==17285== by 0x458444: read_viminfo (ex_cmds.c:1710)
==17285== by 0x478E3D: ex_viminfo (ex_docmd.c:11010)
==17285== by 0x46B583: do_one_cmd (ex_docmd.c:2668)
==17285== by 0x468D24: do_cmdline (ex_docmd.c:1122)
==17285== by 0x466BD1: do_source (ex_cmds2.c:3188)
The number of blocks leaked (6) corresponds to the number
of 'rv! /tmp/foo' commands in script (3) times the number of
list and dictionary variables being read in viminfo file (2 in this
example for FOO and BAR).
Attached patch fixes the leak.
Regards
-- Dominique
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 74686ae0b181 src/eval.c
--- a/src/eval.c Fri Mar 16 20:16:46 2012 +0100
+++ b/src/eval.c Sat Mar 17 18:28:31 2012 +0100
@@ -22971,6 +22971,7 @@
{
vim_free(tv.vval.v_string);
tv = *etv;
+ vim_free(etv);
}
}