diff src/vim9execute.c @ 21787:837e6a429950 v8.2.1443

patch 8.2.1443: Vim9: crash when interrupting a nested :def function Commit: https://github.com/vim/vim/commit/cdd70f09a5340c3d7ae873f1aaaf9847f27410cc Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 13 21:40:18 2020 +0200 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 https://github.com/vim/vim/issues/6701)
author Bram Moolenaar <Bram@vim.org>
date Thu, 13 Aug 2020 21:45:05 +0200
parents fcf978444298
children f84625b961a8
line wrap: on
line diff
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -915,16 +915,17 @@ call_def_function(
 	    }
 	    else
 	    {
-		// not inside try or need to return from current functions.
+		// Not inside try or need to return from current functions.
+		// Push a dummy return value.
+		if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
+		    goto failed;
+		tv = STACK_TV_BOT(0);
+		tv->v_type = VAR_NUMBER;
+		tv->vval.v_number = 0;
+		++ectx.ec_stack.ga_len;
 		if (ectx.ec_frame_idx == initial_frame_idx)
 		{
-		    // At the toplevel we are done.  Push a dummy return value.
-		    if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
-			goto failed;
-		    tv = STACK_TV_BOT(0);
-		    tv->v_type = VAR_NUMBER;
-		    tv->vval.v_number = 0;
-		    ++ectx.ec_stack.ga_len;
+		    // At the toplevel we are done.
 		    need_rethrow = TRUE;
 		    if (handle_closure_in_use(&ectx, FALSE) == FAIL)
 			goto failed;