patch 9.0.1079: leaking memory when defining a user command fails
Problem: Leaking memory when defining a user command fails.
Solution: Free "compl_arg" when needed. (closes #11726)
diff --git a/src/testdir/test_usercommands.vim b/src/testdir/test_usercommands.vim
index 57953ce..d8b4cb4 100644
--- a/src/testdir/test_usercommands.vim
+++ b/src/testdir/test_usercommands.vim
@@ -342,6 +342,11 @@
call assert_fails('com DoCmd :', 'E174:')
comclear
call assert_fails('delcom DoCmd', 'E184:')
+
+ " These used to leak memory
+ call assert_fails('com! -complete=custom,CustomComplete _ :', 'E182:')
+ call assert_fails('com! -complete=custom,CustomComplete docmd :', 'E183:')
+ call assert_fails('com! -complete=custom,CustomComplete -xxx DoCmd :', 'E181:')
endfunc
func CustomComplete(A, L, P)