1
0
forked from aniani/vim

patch 8.2.2136: Vim9: Using uninitialized variable

Problem:    Vim9: Using uninitialized variable.
Solution:   Initialize "len" to zero.  Clean up fnamemodify().
This commit is contained in:
Bram Moolenaar
2020-12-13 12:25:35 +01:00
parent 93f82cbee5
commit c530852315
2 changed files with 7 additions and 4 deletions

View File

@@ -1019,7 +1019,7 @@ f_fnamemodify(typval_T *argvars, typval_T *rettv)
char_u *fname; char_u *fname;
char_u *mods; char_u *mods;
int usedlen = 0; int usedlen = 0;
int len; int len = 0;
char_u *fbuf = NULL; char_u *fbuf = NULL;
char_u buf[NUMBUFLEN]; char_u buf[NUMBUFLEN];
@@ -1028,12 +1028,13 @@ f_fnamemodify(typval_T *argvars, typval_T *rettv)
return; return;
fname = tv_get_string_chk(&argvars[0]); fname = tv_get_string_chk(&argvars[0]);
mods = tv_get_string_buf_chk(&argvars[1], buf); mods = tv_get_string_buf_chk(&argvars[1], buf);
if (fname == NULL) if (mods == NULL || fname == NULL)
fname = NULL; fname = NULL;
else if (mods != NULL && *mods != NUL) else
{ {
len = (int)STRLEN(fname); len = (int)STRLEN(fname);
(void)modify_fname(mods, FALSE, &usedlen, &fname, &fbuf, &len); if (mods != NULL && *mods != NUL)
(void)modify_fname(mods, FALSE, &usedlen, &fname, &fbuf, &len);
} }
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;

View File

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