Dominique Pelle wrote:
> I found another memory leak in vim-7.1.137 > > Steps to reproduce: > > 1/ start vim with a remote file (content of the actual file does not > matter I think) > > $ valgrind --leak-check=yes \ > --track-fds=yes \ > --num-callers=19 \ > ./vim http://dominique.pelle.free.fr/.vimrc 2> vg.log > > 2/ source the file and quit > > :so % > :q! > > 3/ observe that valgrind reports the following leak: > > ==6256== 20 bytes in 1 blocks are definitely lost in loss record 2 of 15 > ==6256== at 0x4021620: malloc (vg_replace_malloc.c:149) > ==6256== by 0x8102F4C: lalloc (misc2.c:857) > ==6256== by 0x8102E6E: alloc (misc2.c:756) > ==6256== by 0x81032AD: vim_strsave (misc2.c:1144) > ==6256== by 0x80FB289: FullName_save (misc1.c:4693) > ==6256== by 0x8051AE2: fix_fname (buffer.c:4182) > ==6256== by 0x8096D44: do_source (ex_cmds2.c:2815) > ==6256== by 0x8096CB1: cmd_source (ex_cmds2.c:2684) > ==6256== by 0x8096C0A: ex_source (ex_cmds2.c:2657) > ==6256== by 0x809B897: do_one_cmd (ex_docmd.c:2621) > ==6256== by 0x80990FC: do_cmdline (ex_docmd.c:1099) > ==6256== by 0x8116F33: nv_colon (normal.c:5168) > ==6256== by 0x8111067: normal_cmd (normal.c:1141) > ==6256== by 0x80D7D52: main_loop (main.c:1181) > ==6256== by 0x80D7966: main (main.c:940) > > The problem is in do_source() which returns without > freeing fname_exp at lines 2831 and 2833 in ex_cmds2.c: > > 2815 fname_exp = fix_fname(p); <--- fname_exp (local var) > dynamically allocated > 2816 vim_free(p); > 2817 if (fname_exp == NULL) > 2818 return retval; > 2819 if (mch_isdir(fname_exp)) > 2820 { > 2821 smsg((char_u *)_("Cannot source a directory: \"%s\""), fname); > 2822 goto theend; > 2823 } > 2824 > 2825 #ifdef FEAT_AUTOCMD > 2826 /* Apply SourceCmd autocommands, they should get the file and > source it. */ > 2827 if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL) > 2828 && apply_autocmds(EVENT_SOURCECMD, fname_exp, fname_exp, > 2829 > FALSE, curbuf)) > 2830 # ifdef FEAT_EVAL > 2831 return aborting() ? FAIL : OK; <--- return without > freeing fname_exp > 2832 # else > 2833 return OK; <----------------------- return without > freeing fname_exp > 2834 # endif > > I attach a patch which fixes the leak. > > I used vim-7.1.137 built on Linux with: > - configure --with-features=huge > - changed src/Makefile to compile without optimisation (-O0) > - changed src/Makefile to enable PROFILE_CFLAGS = -DEXITFREE > > /Dominique > > Attached: fix_mem_leak_do_source.patch (1126 bytes) Thanks, I'll consider including it. -- Normal people believe that if it ain't broke, don't fix it. Engineers believe that if it ain't broke, it doesn't have enough features yet. (Scott Adams - The Dilbert principle) /// 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. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
