patch 9.1.1553: Vim9: crash when accessing a variable in if condition

Commit: 
https://github.com/vim/vim/commit/7dd8ee2103cb3a9c92c768b8d92c997ae6c47c1c
Author: Yegappan Lakshmanan <yegap...@yahoo.com>
Date:   Wed Jul 16 18:34:59 2025 +0200

    patch 9.1.1553: Vim9: crash when accessing a variable in if condition
    
    Problem:  Vim9: crash when accessing a variable in if condition
              (lxhillwind)
    Solution: Skip indexing a list/tuple/dict/blob when short-circuiting an
              if condition check (Yegappan Lakshmanan)
    
    fixes: #17756
    closes: #17768
    
    Signed-off-by: Yegappan Lakshmanan <yegap...@yahoo.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/po/vim.pot b/src/po/vim.pot
index 4a9a20bcd..43e194e92 100644
--- a/src/po/vim.pot
+++ b/src/po/vim.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION
"
 "Report-Msgid-Bugs-To: 
"
-"POT-Creation-Date: 2025-07-15 21:50+0200
"
+"POT-Creation-Date: 2025-07-16 18:34+0200
"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>
"
 "Language-Team: LANGUAGE <l...@li.org>
"
@@ -4257,327 +4257,327 @@ msgstr ""
 msgid "%s (%s, compiled %s)"
 msgstr ""
 
-#: ../version.c:4038
+#: ../version.c:4040
 msgid ""
 "
"
 "MS-Windows ARM64 GUI/console version"
 msgstr ""
 
-#: ../version.c:4040
+#: ../version.c:4042
 msgid ""
 "
"
 "MS-Windows 64-bit GUI/console version"
 msgstr ""
 
-#: ../version.c:4043
+#: ../version.c:4045
 msgid ""
 "
"
 "MS-Windows 32-bit GUI/console version"
 msgstr ""
 
-#: ../version.c:4048
+#: ../version.c:4050
 msgid ""
 "
"
 "MS-Windows ARM64 GUI version"
 msgstr ""
 
-#: ../version.c:4050
+#: ../version.c:4052
 msgid ""
 "
"
 "MS-Windows 64-bit GUI version"
 msgstr ""
 
-#: ../version.c:4053
+#: ../version.c:4055
 msgid ""
 "
"
 "MS-Windows 32-bit GUI version"
 msgstr ""
 
-#: ../version.c:4057
+#: ../version.c:4059
 msgid " with OLE support"
 msgstr ""
 
-#: ../version.c:4062
+#: ../version.c:4064
 msgid ""
 "
"
 "MS-Windows ARM64 console version"
 msgstr ""
 
-#: ../version.c:4064
+#: ../version.c:4066
 msgid ""
 "
"
 "MS-Windows 64-bit console version"
 msgstr ""
 
-#: ../version.c:4067
+#: ../version.c:4069
 msgid ""
 "
"
 "MS-Windows 32-bit console version"
 msgstr ""
 
-#: ../version.c:4073
+#: ../version.c:4075
 msgid ""
 "
"
 "macOS version"
 msgstr ""
 
-#: ../version.c:4075
+#: ../version.c:4077
 msgid ""
 "
"
 "macOS version w/o darwin feat."
 msgstr ""
 
-#: ../version.c:4085
+#: ../version.c:4087
 msgid ""
 "
"
 "OpenVMS version"
 msgstr ""
 
-#: ../version.c:4100
+#: ../version.c:4102
 msgid ""
 "
"
 "Included patches: "
 msgstr ""
 
-#: ../version.c:4125
+#: ../version.c:4127
 msgid ""
 "
"
 "Extra patches: "
 msgstr ""
 
-#: ../version.c:4137 ../version.c:4448
+#: ../version.c:4139 ../version.c:4450
 msgid "Modified by "
 msgstr ""
 
-#: ../version.c:4144
+#: ../version.c:4146
 msgid ""
 "
"
 "Compiled "
 msgstr ""
 
-#: ../version.c:4147
+#: ../version.c:4149
 msgid "by "
 msgstr ""
 
-#: ../version.c:4159
+#: ../version.c:4161
 msgid ""
 "
"
 "Huge version "
 msgstr ""
 
-#: ../version.c:4161
+#: ../version.c:4163
 msgid ""
 "
"
 "Normal version "
 msgstr ""
 
-#: ../version.c:4163
+#: ../version.c:4165
 msgid ""
 "
"
 "Tiny version "
 msgstr ""
 
-#: ../version.c:4166
+#: ../version.c:4168
 msgid "without GUI."
 msgstr ""
 
-#: ../version.c:4169
+#: ../version.c:4171
 msgid "with GTK3 GUI."
 msgstr ""
 
-#: ../version.c:4171
+#: ../version.c:4173
 msgid "with GTK2-GNOME GUI."
 msgstr ""
 
-#: ../version.c:4173
+#: ../version.c:4175
 msgid "with GTK2 GUI."
 msgstr ""
 
-#: ../version.c:4176
+#: ../version.c:4178
 msgid "with X11-Motif GUI."
 msgstr ""
 
-#: ../version.c:4178
+#: ../version.c:4180
 msgid "with Haiku GUI."
 msgstr ""
 
-#: ../version.c:4180
+#: ../version.c:4182
 msgid "with Photon GUI."
 msgstr ""
 
-#: ../version.c:4182
+#: ../version.c:4184
 msgid "with GUI."
 msgstr ""
 
-#: ../version.c:4184
+#: ../version.c:4186
 msgid "  Features included (+) or not (-):
"
 msgstr ""
 
-#: ../version.c:4191
+#: ../version.c:4193
 msgid "   system vimrc file: \""
 msgstr ""
 
-#: ../version.c:4196
+#: ../version.c:4198
 msgid "     user vimrc file: \""
 msgstr ""
 
-#: ../version.c:4201
+#: ../version.c:4203
 msgid " 2nd user vimrc file: \""
 msgstr ""
 
-#: ../version.c:4206 ../version.c:4213 ../version.c:4217
+#: ../version.c:4208 ../version.c:4215 ../version.c:4219
 msgid " 3rd user vimrc file: \""
 msgstr ""
 
-#: ../version.c:4209
+#: ../version.c:4211
 msgid " 4th user vimrc file: \""
 msgstr ""
 
-#: ../version.c:4222
+#: ../version.c:4224
 msgid "      user exrc file: \""
 msgstr ""
 
-#: ../version.c:4227
+#: ../version.c:4229
 msgid "  2nd user exrc file: \""
 msgstr ""
 
-#: ../version.c:4233
+#: ../version.c:4235
 msgid "  system gvimrc file: \""
 msgstr ""
 
-#: ../version.c:4237
+#: ../version.c:4239
 msgid "    user gvimrc file: \""
 msgstr ""
 
-#: ../version.c:4241
+#: ../version.c:4243
 msgid "2nd user gvimrc file: \""
 msgstr ""
 
-#: ../version.c:4246
+#: ../version.c:4248
 msgid "3rd user gvimrc file: \""
 msgstr ""
 
-#: ../version.c:4251
+#: ../version.c:4253
 msgid "       defaults file: \""
 msgstr ""
 
-#: ../version.c:4256
+#: ../version.c:4258
 msgid "    system menu file: \""
 msgstr ""
 
-#: ../version.c:4264
+#: ../version.c:4266
 msgid "  fall-back for $VIM: \""
 msgstr ""
 
-#: ../version.c:4270
+#: ../version.c:4272
 msgid " f-b for $VIMRUNTIME: \""
 msgstr ""
 
-#: ../version.c:4274
+#: ../version.c:4276
 msgid "Compilation: "
 msgstr ""
 
-#: ../version.c:4280
+#: ../version.c:4282
 msgid "Compiler: "
 msgstr ""
 
-#: ../version.c:4285
+#: ../version.c:4287
 msgid "Linking: "
 msgstr ""
 
-#: ../version.c:4290
+#: ../version.c:4292
 msgid "  DEBUG BUILD"
 msgstr ""
 
-#: ../version.c:4326
+#: ../version.c:4328
 msgid "VIM - Vi IMproved"
 msgstr ""
 
-#: ../version.c:4328
+#: ../version.c:4330
 msgid "version "
 msgstr ""
 
-#: ../version.c:4329
+#: ../version.c:4331
 msgid "by Bram Moolenaar et al."
 msgstr ""
 
-#: ../version.c:4333
+#: ../version.c:4335
 msgid "Vim is open source and freely distributable"
 msgstr ""
 
-#: ../version.c:4335
+#: ../version.c:4337
 msgid "Help poor children in Uganda!"
 msgstr ""
 
-#: ../version.c:4336
+#: ../version.c:4338
 msgid "type  :help iccf<Enter>       for information "
 msgstr ""
 
-#: ../version.c:4338
+#: ../version.c:4340
 msgid "type  :q<Enter>               to exit         "
 msgstr ""
 
-#: ../version.c:4339
+#: ../version.c:4341
 msgid "type  :help<Enter>  or  <F1>  for on-line help"
 msgstr ""
 
-#: ../version.c:4340
+#: ../version.c:4342
 msgid "type  :help version9<Enter>   for version info"
 msgstr ""
 
-#: ../version.c:4343
+#: ../version.c:4345
 msgid "Running in Vi compatible mode"
 msgstr ""
 
-#: ../version.c:4344
+#: ../version.c:4346
 msgid "type  :set nocp<Enter>        for Vim defaults"
 msgstr ""
 
-#: ../version.c:4345
+#: ../version.c:4347
 msgid "type  :help cp-default<Enter> for info on this"
 msgstr ""
 
-#: ../version.c:4360
+#: ../version.c:4362
 msgid "menu  Help->Orphans           for information    "
 msgstr ""
 
-#: ../version.c:4362
+#: ../version.c:4364
 msgid "Running modeless, typed text is inserted"
 msgstr ""
 
-#: ../version.c:4363
+#: ../version.c:4365
 msgid "menu  Edit->Global Settings->Toggle Insert Mode  "
 msgstr ""
 
-#: ../version.c:4364
+#: ../version.c:4366
 msgid "                              for two modes      "
 msgstr ""
 
-#: ../version.c:4368
+#: ../version.c:4370
 msgid "menu  Edit->Global Settings->Toggle Vi Compatible"
 msgstr ""
 
-#: ../version.c:4369
+#: ../version.c:4371
 msgid "                              for Vim defaults   "
 msgstr ""
 
-#: ../version.c:4410
+#: ../version.c:4412
 msgid "Sponsor Vim development!"
 msgstr ""
 
-#: ../version.c:4411
+#: ../version.c:4413
 msgid "Become a registered Vim user!"
 msgstr ""
 
-#: ../version.c:4414
+#: ../version.c:4416
 msgid "type  :help sponsor<Enter>    for information "
 msgstr ""
 
-#: ../version.c:4415
+#: ../version.c:4417
 msgid "type  :help register<Enter>   for information "
 msgstr ""
 
-#: ../version.c:4417
+#: ../version.c:4419
 msgid "menu  Help->Sponsor/Register  for information    "
 msgstr ""
 
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 2e70a3ba9..268ceb482 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -5361,6 +5361,78 @@ def Test_len_func_shortcircuit()
   assert_equal('match', Len_Or2_Cond())
 enddef
 
+" Test for skipping list/tuple/dict/blob indexing when short circuiting a if
+" condition check.
+def Test_if_cond_shortcircuit_skip_indexing()
+  # indexing a list
+  var lines =<< trim END
+    vim9script
+    def Foo(): string
+      const l = [false]
+      if false && l[0]
+        return 'failed'
+      endif
+      if true || l[0]
+        return 'passed'
+      endif
+      return 'failed'
+    enddef
+    assert_equal('passed', Foo())
+  END
+  v9.CheckSourceSuccess(lines)
+
+  # indexing a tuple
+  lines =<< trim END
+    vim9script
+    def Foo(): string
+      const t = (false)
+      if false && t[0]
+        return 'failed'
+      endif
+      if true || t[0]
+        return 'passed'
+      endif
+      return 'failed'
+    enddef
+    assert_equal('passed', Foo())
+  END
+  v9.CheckSourceSuccess(lines)
+
+  # indexing a dict
+  lines =<< trim END
+    vim9script
+    def Foo(): string
+      const d = {x: false}
+      if false && d['x']
+        return 'failed'
+      endif
+      if true || d['x']
+        return 'passed'
+      endif
+      return 'failed'
+    enddef
+    assert_equal('passed', Foo())
+  END
+  v9.CheckSourceSuccess(lines)
+
+  # indexing a blob
+  lines =<< trim END
+    vim9script
+    def Foo(): string
+      const b = 0z00
+      if false && b[0]
+        return 'failed'
+      endif
+      if true || b[0]
+        return 'passed'
+      endif
+      return 'failed'
+    enddef
+    assert_equal('passed', Foo())
+  END
+  v9.CheckSourceSuccess(lines)
+enddef
+
 " Keep this last, it messes up highlighting.
 def Test_substitute_cmd()
   new
diff --git a/src/version.c b/src/version.c
index 98c397cb6..1ffb15426 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1553,
 /**/
     1552,
 /**/
diff --git a/src/vim9expr.c b/src/vim9expr.c
index 33c0dafb7..715771c7d 100644
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -2684,7 +2684,8 @@ compile_subscript(
                if (generate_instr(cctx, ISN_CLEARDICT) == NULL)
                    return FAIL;
            }
-           if (compile_member(is_slice, &keeping_dict, cctx) == FAIL)
+           if (cctx->ctx_skip != SKIP_YES
+                   && compile_member(is_slice, &keeping_dict, cctx) == FAIL)
                return FAIL;
        }
        else if (*p == '.' && p[1] != '.')

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1uc5Fk-009UFQ-2q%40256bit.org.

Raspunde prin e-mail lui