Skip to content

Commit cb90ea9

Browse files
erraelchrisbra
authored andcommitted
patch 9.1.0682: Vim9: Segfault with uninitialized funcref
Problem: Vim9: Segfault with uninitialized funcref (Daniel Viberg) Solution: Check the Funcref for being Null before trying to access it (Ernie Rael) fixes: #15523 Signed-off-by: Ernie Rael <errael@raelity.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 6bff6a2 commit cb90ea9

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/testdir/test_vim9_func.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ def Test_wrong_function_name()
164164
END
165165
v9.CheckScriptFailure(lines, 'E1182:')
166166
delfunc g:Define
167+
168+
lines =<< trim END
169+
vim9script
170+
var F1_ref: func
171+
def Start()
172+
F1_ref()
173+
enddef
174+
Start()
175+
END
176+
v9.CheckScriptFailure(lines, 'E117:')
167177
enddef
168178

169179
" Check that in a legacy script a :def accesses the correct script variables.

src/userfunc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2245,7 +2245,8 @@ find_func_imported(char_u *name, int flags)
22452245
if (!HASHITEM_EMPTY(hi))
22462246
{
22472247
dictitem_T *di = HI2DI(hi);
2248-
if (di->di_tv.v_type == VAR_FUNC)
2248+
if (di->di_tv.v_type == VAR_FUNC
2249+
&& di->di_tv.vval.v_string != NULL)
22492250
func = find_func_even_dead(di->di_tv.vval.v_string, flags);
22502251
}
22512252
}

src/version.c

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

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
682,
707709
/**/
708710
681,
709711
/**/

0 commit comments

Comments
 (0)