]> granicus.if.org Git - vim/commitdiff
patch 9.0.0224: Using NULL pointer when skipping compiled code v9.0.0224
authorBram Moolenaar <Bram@vim.org>
Wed, 17 Aug 2022 14:55:51 +0000 (15:55 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 17 Aug 2022 14:55:51 +0000 (15:55 +0100)
Problem:    Using NULL pointer when skipping compiled code.
Solution:   Check for skipping.

src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c

index 3199ac3953740e6711b4f2309a587589a924b715..56a39efcf79bcf5b8f0b8b34201744e7885b50d4 100644 (file)
@@ -2097,6 +2097,19 @@ def Test_for_skipped_block()
   v9.CheckDefAndScriptSuccess(lines)
 enddef
 
+def Test_skipped_redir()
+  var lines =<< trim END
+      def T()
+        if 0
+          redir =>l[0]
+          redir END
+        endif
+      enddef
+      defcompile
+  END
+  v9.CheckScriptSuccess(lines)
+enddef
+
 def Test_for_loop()
   var lines =<< trim END
       var result = ''
index 1566e4dfcfcfbe2e9a2c835ad6ae08894d9eb661..e477f9e315d0e8d17720d3098858955eb680ba4d 100644 (file)
@@ -731,6 +731,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    224,
 /**/
     223,
 /**/
index d1e2c87fd82c6c3c9af0b8ccb0d00e8bffcb357c..d8596e99effb490dcc9509467b4ab9fc547a884f 100644 (file)
@@ -1165,11 +1165,14 @@ generate_loadvar(
            generate_LOADV(cctx, name + 2);
            break;
        case dest_local:
-           if (lvar->lv_from_outer > 0)
-               generate_LOADOUTER(cctx, lvar->lv_idx, lvar->lv_from_outer,
+           if (cctx->ctx_skip != SKIP_YES)
+           {
+               if (lvar->lv_from_outer > 0)
+                   generate_LOADOUTER(cctx, lvar->lv_idx, lvar->lv_from_outer,
                                                                         type);
-           else
-               generate_LOAD(cctx, ISN_LOAD, lvar->lv_idx, NULL, type);
+               else
+                   generate_LOAD(cctx, ISN_LOAD, lvar->lv_idx, NULL, type);
+           }
            break;
        case dest_expr:
            // list or dict value should already be on the stack.
@@ -1952,6 +1955,9 @@ compile_assign_unlet(
        }
     }
 
+    if (cctx->ctx_skip == SKIP_YES)
+       return OK;
+
     // Load the dict or list.  On the stack we then have:
     // - value (for assignment, not for :unlet)
     // - index