Hi

I can reproduce a memory leak with Vim-7.2.293 (and older).

Steps to reproduce:

1/ Create the following minimalistic script:

  $ cat leak.vim

  function Foo()
    redraw!
    return ''
  endfunction

  set hlsearch
  set laststatus=2
  set statusline=%{Foo()}

2/ Start Vim with Valgrind using:

   $ cd vim7/src
   $ valgrind --leak-check=yes ./vim \
       --noplugin \
       -u leak.vim buffer.c \
       -c 'exe "normal /to\<CR>"' 2> vg.log

3/ Press   n   several times (press 3 times for example) to go to next
   match several times.

4/ Quit Vim with:

   :q!

5/ Observe in vg.log the following memory leaks:

==15737== 164 bytes in 4 blocks are definitely lost in loss record 100 of 113
==15737==    at 0x402603E: malloc (vg_replace_malloc.c:207)
==15737==    by 0x8115C72: lalloc (misc2.c:866)
==15737==    by 0x815AAF7: vim_regcomp (regexp.c:1021)
==15737==    by 0x81747EA: search_regcomp (search.c:216)
==15737==    by 0x817505C: last_pat_prog (search.c:501)
==15737==    by 0x816F71E: start_search_hl (screen.c:6590)
==15737==    by 0x816488C: update_screen (screen.c:505)
==15737==    by 0x80E7C97: main_loop (main.c:1121)
==15737==    by 0x80E792D: main (main.c:948)

One block is leaked when doing the first search with  /to  then
other blocks are leaked every time you press  n  to go to next
match.  In above example I pressed  n  3 times so there was 1+3=4
leaks in total.

Attached patch fixes it.

Regards
-- Dominique

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

Index: screen.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/screen.c,v
retrieving revision 1.126
diff -c -r1.126 screen.c
*** screen.c	11 Nov 2009 16:07:16 -0000	1.126
--- screen.c	14 Nov 2009 09:08:54 -0000
***************
*** 490,496 ****
      did_one = FALSE;
  #endif
  #ifdef FEAT_SEARCH_EXTRA
!     search_hl.rm.regprog = NULL;
  #endif
      FOR_ALL_WINDOWS(wp)
      {
--- 490,496 ----
      did_one = FALSE;
  #endif
  #ifdef FEAT_SEARCH_EXTRA
!     end_search_hl();
  #endif
      FOR_ALL_WINDOWS(wp)
      {

Raspunde prin e-mail lui