Dominique Pelle wrote:

> The following script reproduces a memory leak
> which happens when encrypting a buffer several
> times with different keys:
> 
> $ cat leak.vim
> for i in range(1, 5)
>   call feedkeys(":X\<CR>foo\<CR>foo\<CR>")
>   call feedkeys(":X\<CR>bar\<CR>bar\<CR>")
> endfor
> 
> $ rm /tmp/foo; valgrind --leak-check=yes vim -u NONE /tmo/foo -S leak.vim
> 
> ==3281== 84 bytes in 1 blocks are definitely lost in loss record 89 of 114
> ==3281==    at 0x4024F70: malloc (vg_replace_malloc.c:236)
> ==3281==    by 0x8115FEE: lalloc (misc2.c:920)
> ==3281==    by 0x8115EDE: alloc (misc2.c:818)
> ==3281==    by 0x80FB52A: ml_add_stack (memline.c:3800)
> ==3281==    by 0x80FB289: ml_find_line (memline.c:3704)
> ==3281==    by 0x80F9329: ml_get_buf (memline.c:2474)
> ==3281==    by 0x80F91C5: ml_get (memline.c:2390)
> ==3281==    by 0x805AE20: chk_modeline (buffer.c:4881)
> ==3281==    by 0x805AD7C: do_modelines (buffer.c:4846)
> ==3281==    by 0x805369B: open_buffer (buffer.c:263)
> ==3281==    by 0x80E9B4F: create_windows (main.c:2545)
> ==3281==    by 0x80E7613: main (main.c:804)
> 
> -> this leak happens only once
> 
> 
> ==3281== 756 bytes in 9 blocks are definitely lost in loss record 101 of 114
> ==3281==    at 0x4024F70: malloc (vg_replace_malloc.c:236)
> ==3281==    by 0x8115FEE: lalloc (misc2.c:920)
> ==3281==    by 0x8115EDE: alloc (misc2.c:818)
> ==3281==    by 0x80FB52A: ml_add_stack (memline.c:3800)
> ==3281==    by 0x80F5EA1: ml_set_crypt_key (memline.c:547)
> ==3281==    by 0x8142452: did_set_string_option (option.c:5983)
> ==3281==    by 0x81416F0: set_string_option (option.c:5514)
> ==3281==    by 0x814684B: set_option_value (option.c:8532)
> ==3281==    by 0x8119429: get_crypt_key (misc2.c:3943)
> ==3281==    by 0x80B484E: ex_X (ex_docmd.c:11165)
> ==3281==    by 0x80A797C: do_one_cmd (ex_docmd.c:2640)
> ==3281==    by 0x80A5255: do_cmdline (ex_docmd.c:1109)
> 
> -> This leak happens 2*n - 1 times
>    n being the number of iteration of loop in leak.vim
>    In this example: 2*5 - 1 -> 9 blocks leaked
> 
> Attached patch fixes it.

Thanks, I'll include it.

-- 
hundred-and-one symptoms of being an internet addict:
237. You tattoo your email address on your forehead.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
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

Raspunde prin e-mail lui