Hi
Valgrind memory checker detects the following memory leak:
==2410== 272 (56 direct, 216 indirect) bytes in 1 blocks are
definitely lost in loss record 2>
==2410== at 0x4C21FEB: malloc (vg_replace_malloc.c:207)
==2410== by 0x6F7548A: (within /lib64/libacl.so.1.1.0)
==2410== by 0x6F73EE6: (within /lib64/libacl.so.1.1.0)
==2410== by 0x6F746F1: acl_from_mode (in /lib64/libacl.so.1.1.0)
==2410== by 0x6F73D2F: acl_get_file (in /lib64/libacl.so.1.1.0)
==2410== by 0x50FFDC: mch_get_acl (os_unix.c:2658)
==2410== by 0x4895C5: vim_rename (fileio.c:6163)
==2410== by 0x4B58A2: ml_setname (memline.c:467)
==2410== by 0x4123CE: buf_name_changed (buffer.c:2698)
==2410== by 0x4122FE: setfname (buffer.c:2657)
==2410== by 0x453DE7: ex_file (ex_cmds.c:2464)
==2410== by 0x465179: do_one_cmd (ex_docmd.c:2621)
==2410== by 0x462959: do_cmdline (ex_docmd.c:1095)
==2410== by 0x4EDE83: nv_colon (normal.c:5181)
==2410== by 0x4E6E73: normal_cmd (normal.c:1152)
==2410== by 0x4A73A1: main_loop (main.c:1177)
==2410== by 0x4A6EED: main (main.c:936)
I can reproduce it with "Vim-7.2a BETA" (huge) built with libacl and using
a file system mounted with acl option on Linux x86_64.
Here is how I can reproduce it 100% of the time (there might be other ways):
1/ Start Vim with Valgrind:
$ valgrind --leak-check=yes vim -u NONE /tmp/foo 2> vg.log
2/ Change the file name to a location on a filesystem mounted with acl and where
you don't have write permission (/ for example for me):
:file /foo
For me, / is the following filesystem (note the acl mount option)
/dev/sda2 on / type reiserfs (rw,acl,user_xattr)
3/ Quit Vim :q and observe in vg.log that Valgrind detected a leak (as
many leaks as ":file /foo" command was entered)
I attach a patch which fixes it.
-- Dominique
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Index: fileio.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/fileio.c,v
retrieving revision 1.117
diff -c -r1.117 fileio.c
*** fileio.c 24 Jun 2008 21:02:45 -0000 1.117
--- fileio.c 26 Jun 2008 08:27:57 -0000
***************
*** 2456,2462 ****
/*
* Work around a weird problem: When a file has two links (only
* possible on NTFS) and we write through one link, then stat() it
! * throught the other link, the timestamp information may be wrong.
* It's correct again after reading the file, thus reset the timestamp
* here.
*/
--- 2456,2462 ----
/*
* Work around a weird problem: When a file has two links (only
* possible on NTFS) and we write through one link, then stat() it
! * through the other link, the timestamp information may be wrong.
* It's correct again after reading the file, thus reset the timestamp
* here.
*/
***************
*** 3906,3912 ****
#ifdef VMS
vms_remove_version(fname); /* remove version */
#endif
! /* Default: write the the file directly. May write to a temp file for
* multi-byte conversion. */
wfname = fname;
--- 3906,3912 ----
#ifdef VMS
vms_remove_version(fname); /* remove version */
#endif
! /* Default: write the file directly. May write to a temp file for
* multi-byte conversion. */
wfname = fname;
***************
*** 5770,5776 ****
#endif
/*
! * add extention to file name - change path/fo.o.h to path/fo.o.h.ext or
* fo_o_h.ext for MSDOS or when shortname option set.
*
* Assumed that fname is a valid name found in the filesystem we assure that
--- 5770,5776 ----
#endif
/*
! * add extension to file name - change path/fo.o.h to path/fo.o.h.ext or
* fo_o_h.ext for MSDOS or when shortname option set.
*
* Assumed that fname is a valid name found in the filesystem we assure that
***************
*** 5952,5958 ****
#endif
/*
! * Append the extention.
* ext can start with '.' and cannot exceed 3 more characters.
*/
STRCPY(s, ext);
--- 5952,5958 ----
#endif
/*
! * Append the extension.
* ext can start with '.' and cannot exceed 3 more characters.
*/
STRCPY(s, ext);
***************
*** 6164,6176 ****
--- 6164,6184 ----
#endif
fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
if (fd_in == -1)
+ {
+ #ifdef HAVE_ACL
+ mch_free_acl(acl);
+ #endif
return -1;
+ }
/* Create the new file with same permissions as the original. */
fd_out = mch_open((char *)to,
O_CREAT|O_EXCL|O_WRONLY|O_EXTRA|O_NOFOLLOW, (int)perm);
if (fd_out == -1)
{
+ #ifdef HAVE_ACL
+ mch_free_acl(acl);
+ #endif
close(fd_in);
return -1;
}
***************
*** 6178,6183 ****
--- 6186,6194 ----
buffer = (char *)alloc(BUFSIZE);
if (buffer == NULL)
{
+ #ifdef HAVE_ACL
+ mch_free_acl(acl);
+ #endif
close(fd_in);
close(fd_out);
return -1;
***************
*** 6204,6209 ****
--- 6215,6221 ----
#endif
#ifdef HAVE_ACL
mch_set_acl(to, acl);
+ mch_free_acl(acl);
#endif
if (errmsg != NULL)
{