Skip to content

Commit cdd70f0

Browse files
committed
patch 8.2.1443: Vim9: crash when interrupting a nested :def function
Problem: Vim9: crash when interrupting a nested :def function. Solution: Push a dummy return value onto the stack. (closes #6701)
1 parent be7529e commit cdd70f0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1443,
757759
/**/
758760
1442,
759761
/**/

src/vim9execute.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -915,16 +915,17 @@ call_def_function(
915915
}
916916
else
917917
{
918-
// not inside try or need to return from current functions.
918+
// Not inside try or need to return from current functions.
919+
// Push a dummy return value.
920+
if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
921+
goto failed;
922+
tv = STACK_TV_BOT(0);
923+
tv->v_type = VAR_NUMBER;
924+
tv->vval.v_number = 0;
925+
++ectx.ec_stack.ga_len;
919926
if (ectx.ec_frame_idx == initial_frame_idx)
920927
{
921-
// At the toplevel we are done. Push a dummy return value.
922-
if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
923-
goto failed;
924-
tv = STACK_TV_BOT(0);
925-
tv->v_type = VAR_NUMBER;
926-
tv->vval.v_number = 0;
927-
++ectx.ec_stack.ga_len;
928+
// At the toplevel we are done.
928929
need_rethrow = TRUE;
929930
if (handle_closure_in_use(&ectx, FALSE) == FAIL)
930931
goto failed;

0 commit comments

Comments
 (0)