0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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 <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yegappan Lakshmanan 2025-07-16 18:34:59 +02:00 committed by Christian Brabandt
parent 9962c092cc
commit 7dd8ee2103
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
4 changed files with 157 additions and 82 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-07-15 21:50+0200\n"
"POT-Creation-Date: 2025-07-16 18:34+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -4257,327 +4257,327 @@ msgstr ""
msgid "%s (%s, compiled %s)"
msgstr ""
#: ../version.c:4038
#: ../version.c:4040
msgid ""
"\n"
"MS-Windows ARM64 GUI/console version"
msgstr ""
#: ../version.c:4040
#: ../version.c:4042
msgid ""
"\n"
"MS-Windows 64-bit GUI/console version"
msgstr ""
#: ../version.c:4043
#: ../version.c:4045
msgid ""
"\n"
"MS-Windows 32-bit GUI/console version"
msgstr ""
#: ../version.c:4048
#: ../version.c:4050
msgid ""
"\n"
"MS-Windows ARM64 GUI version"
msgstr ""
#: ../version.c:4050
#: ../version.c:4052
msgid ""
"\n"
"MS-Windows 64-bit GUI version"
msgstr ""
#: ../version.c:4053
#: ../version.c:4055
msgid ""
"\n"
"MS-Windows 32-bit GUI version"
msgstr ""
#: ../version.c:4057
#: ../version.c:4059
msgid " with OLE support"
msgstr ""
#: ../version.c:4062
msgid ""
"\n"
"MS-Windows ARM64 console version"
msgstr ""
#: ../version.c:4064
msgid ""
"\n"
"MS-Windows ARM64 console version"
msgstr ""
#: ../version.c:4066
msgid ""
"\n"
"MS-Windows 64-bit console version"
msgstr ""
#: ../version.c:4067
#: ../version.c:4069
msgid ""
"\n"
"MS-Windows 32-bit console version"
msgstr ""
#: ../version.c:4073
#: ../version.c:4075
msgid ""
"\n"
"macOS version"
msgstr ""
#: ../version.c:4075
#: ../version.c:4077
msgid ""
"\n"
"macOS version w/o darwin feat."
msgstr ""
#: ../version.c:4085
#: ../version.c:4087
msgid ""
"\n"
"OpenVMS version"
msgstr ""
#: ../version.c:4100
#: ../version.c:4102
msgid ""
"\n"
"Included patches: "
msgstr ""
#: ../version.c:4125
#: ../version.c:4127
msgid ""
"\n"
"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 ""
"\n"
"Compiled "
msgstr ""
#: ../version.c:4147
#: ../version.c:4149
msgid "by "
msgstr ""
#: ../version.c:4159
msgid ""
"\n"
"Huge version "
msgstr ""
#: ../version.c:4161
msgid ""
"\n"
"Normal version "
"Huge version "
msgstr ""
#: ../version.c:4163
msgid ""
"\n"
"Normal version "
msgstr ""
#: ../version.c:4165
msgid ""
"\n"
"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 (-):\n"
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 ""

View File

@ -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

View File

@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1553,
/**/
1552,
/**/

View File

@ -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] != '.')