Hi

I see the following memory leak in gVim-7.2.411 when built
with the Motif GUI:

==15793== 6 bytes in 6 blocks are definitely lost in loss record 44 of 1,836
==15793==    at 0x4024F70: malloc (vg_replace_malloc.c:236)
==15793==    by 0x43A4027: XtMalloc (in /usr/lib/libXt.so.6.0.0)
==15793==    by 0x413C538: XmTextFieldGetString (in /usr/lib/libXm.so.2.0.1)
==15793==    by 0x4138890: XmTextGetString (in /usr/lib/libXm.so.2.0.1)
==15793==    by 0x81C73C9: gui_mch_dialog (gui_motif.c:2915)
==15793==    by 0x80FDBF3: do_dialog (message.c:3318)
==15793==    by 0x807D5F3: f_inputdialog (eval.c:12383)
==15793==    by 0x80782A5: call_func (eval.c:8155)
==15793==    by 0x8077DF7: get_func_tv (eval.c:7972)
==15793==    by 0x80743CF: eval7 (eval.c:5019)
==15793==    by 0x8073CE8: eval6 (eval.c:4686)
==15793==    by 0x80738DE: eval5 (eval.c:4502)
==15793==    by 0x8072E88: eval4 (eval.c:4197)
==15793==    by 0x8072CF6: eval3 (eval.c:4109)
==15793==    by 0x8072B98: eval2 (eval.c:4038)
==15793==    by 0x80729E9: eval1 (eval.c:3963)
==15793==    by 0x8072954: eval0 (eval.c:3920)
==15793==    by 0x806F29B: ex_let (eval.c:1835)
==15793==    by 0x80A22C8: do_one_cmd (ex_docmd.c:2629)
==15793==    by 0x809FBA1: do_cmdline (ex_docmd.c:1098)
==15793==    by 0x808BDF4: call_user_func (eval.c:21324)
==15793==    by 0x80781A3: call_func (eval.c:8126)
==15793==    by 0x8077DF7: get_func_tv (eval.c:7972)
==15793==    by 0x8071B3E: ex_call (eval.c:3343)
==15793==    by 0x80A22C8: do_one_cmd (ex_docmd.c:2629)
==15793==    by 0x809FBA1: do_cmdline (ex_docmd.c:1098)
==15793==    by 0x8123D4A: nv_colon (normal.c:5224)
==15793==    by 0x811D5ED: normal_cmd (normal.c:1188)
==15793==    by 0x80E16BA: main_loop (main.c:1211)
==15793==    by 0x80E11B1: main (main.c:955)

One block is leaked whenever you click on the icon
"Search Vim Help" which is the icon most at the right
in the icon toolbar.  I clicked 6 times, and I observed
6 leaks for example.

Caller of XmTextGetString(...) is meant to free the returned
string by calling XtFree(...).  See:

http://linux.die.net/man/3/xmtextgetstring
http://www.rahul.net/kenton/txa/mar96.html

Attached patch fixes it.

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

To unsubscribe from this group, send email to 
vim_dev+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.
diff -r 24100651daa9 src/gui_motif.c
--- a/src/gui_motif.c	Tue Mar 23 18:22:46 2010 +0100
+++ b/src/gui_motif.c	Thu Mar 25 22:05:24 2010 +0100
@@ -2917,6 +2917,7 @@
 	    *textfield = NUL;
 	else
 	    vim_strncpy(textfield, p, IOSIZE - 1);
+	XtFree((char *)p);
     }
 
     suppress_dialog_mnemonics(dialogform);

Raspunde prin e-mail lui