[patch] command :helpt {dir} leaks memory when directory does not exist

32 views
Skip to first unread message

Dominique Pellé

unread,
Nov 6, 2015, 6:38:08 PM11/6/15
to vim_dev
Hi

afl-fuzz found that command :helpt {dir} leaks memory
in Vim-7.4.909 when the directory argument does not
exist (E150). Valgrind says:

==4962== 2 bytes in 1 blocks are definitely lost in loss record 1 of 125
==4962== at 0x4C2AB80: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4962== by 0x4E27E3: lalloc (misc2.c:921)
==4962== by 0x4E26F1: alloc (misc2.c:820)
==4962== by 0x4E2BF4: vim_strsave (misc2.c:1246)
==4962== by 0x486B15: ExpandOne (ex_getln.c:3686)
==4962== by 0x460C19: ex_helptags (ex_cmds.c:6572)
==4962== by 0x46E052: do_one_cmd (ex_docmd.c:2961)
==4962== by 0x46AD47: do_cmdline (ex_docmd.c:1133)
==4962== by 0x46A383: do_cmdline_cmd (ex_docmd.c:738)
==4962== by 0x5DD77A: exe_commands (main.c:2926)
==4962== by 0x5DAD5C: main (main.c:961)

Leak can be reproduced with:

$ vim -u NONE -c 'helpt@'

Attached patch fixes it.

Regards
Dominique
fix-leak-E150-ex_cmds.c-7.4.909.patch

Bram Moolenaar

unread,
Nov 8, 2015, 2:48:00 PM11/8/15
to Dominique Pellé, vim_dev
Thanks!

--
From "know your smileys":
:-{} Too much lipstick

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages