delfunc Fail
endfunc
+func Test_func_return_in_try_verbose()
+ func TryReturnList()
+ try
+ return [1, 2, 3]
+ endtry
+ endfunc
+ func TryReturnNumber()
+ try
+ return 123
+ endtry
+ endfunc
+ func TryReturnOverlongString()
+ try
+ return repeat('a', 9999)
+ endtry
+ endfunc
+
+ " This should not cause heap-use-after-free
+ call assert_match('\n:return \[1, 2, 3\] made pending\n',
+ \ execute('14verbose call TryReturnList()'))
+ " This should not cause stack-use-after-scope
+ call assert_match('\n:return 123 made pending\n',
+ \ execute('14verbose call TryReturnNumber()'))
+ " An overlong string is truncated
+ call assert_match('\n:return a\{100,}\.\.\.',
+ \ execute('14verbose call TryReturnOverlongString()'))
+
+ delfunc TryReturnList
+ delfunc TryReturnNumber
+ delfunc TryReturnOverlongString
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
return buf;
}
-/*
- * Get a name for a lambda. Returned in static memory.
- */
static char_u lambda_name[8 + NUMBUFLEN];
static size_t lambda_namelen = 0;
+/*
+ * Get a name for a lambda. Returned in static memory.
+ */
char_u *
get_lambda_name(void)
{
get_return_cmd(void *rettv)
{
char_u *s = NULL;
+ char_u *tofree = NULL;
+ char_u numbuf[NUMBUFLEN];
size_t slen = 0;
size_t IObufflen;
if (rettv != NULL)
- {
- char_u *tofree = NULL;
- char_u numbuf[NUMBUFLEN];
-
s = echo_string((typval_T *)rettv, &tofree, numbuf, 0);
- vim_free(tofree);
- }
if (s == NULL)
s = (char_u *)"";
else
STRCPY(IObuff, ":return ");
STRNCPY(IObuff + 8, s, IOSIZE - 8);
IObufflen = 8 + slen;
- if (slen + 8 >= IOSIZE)
+ if (IObufflen >= IOSIZE)
{
STRCPY(IObuff + IOSIZE - 4, "...");
- IObufflen += 3;
+ IObufflen = IOSIZE - 1;
}
+ vim_free(tofree);
return vim_strnsave(IObuff, IObufflen);
}
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1066,
/**/
1065,
/**/