Skip to content

Commit c530852

Browse files
committed
patch 8.2.2136: Vim9: Using uninitialized variable
Problem: Vim9: Using uninitialized variable. Solution: Initialize "len" to zero. Clean up fnamemodify().
1 parent 93f82cb commit c530852

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/filepath.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ f_fnamemodify(typval_T *argvars, typval_T *rettv)
10191019
char_u *fname;
10201020
char_u *mods;
10211021
int usedlen = 0;
1022-
int len;
1022+
int len = 0;
10231023
char_u *fbuf = NULL;
10241024
char_u buf[NUMBUFLEN];
10251025

@@ -1028,12 +1028,13 @@ f_fnamemodify(typval_T *argvars, typval_T *rettv)
10281028
return;
10291029
fname = tv_get_string_chk(&argvars[0]);
10301030
mods = tv_get_string_buf_chk(&argvars[1], buf);
1031-
if (fname == NULL)
1031+
if (mods == NULL || fname == NULL)
10321032
fname = NULL;
1033-
else if (mods != NULL && *mods != NUL)
1033+
else
10341034
{
10351035
len = (int)STRLEN(fname);
1036-
(void)modify_fname(mods, FALSE, &usedlen, &fname, &fbuf, &len);
1036+
if (mods != NULL && *mods != NUL)
1037+
(void)modify_fname(mods, FALSE, &usedlen, &fname, &fbuf, &len);
10371038
}
10381039

10391040
rettv->v_type = VAR_STRING;

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2136,
753755
/**/
754756
2135,
755757
/**/

0 commit comments

Comments
 (0)