changeset 23181:5f69af863502 v8.2.2136

patch 8.2.2136: Vim9: Using uninitialized variable Commit: https://github.com/vim/vim/commit/c530852315517a44354edbbd6c3375355bbec37e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 13 12:25:35 2020 +0100 patch 8.2.2136: Vim9: Using uninitialized variable Problem: Vim9: Using uninitialized variable. Solution: Initialize "len" to zero. Clean up fnamemodify().
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Dec 2020 12:30:04 +0100
parents 0966c0fbf3f5
children 638099dc139e
files src/filepath.c src/version.c
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -1019,7 +1019,7 @@ f_fnamemodify(typval_T *argvars, typval_
     char_u	*fname;
     char_u	*mods;
     int		usedlen = 0;
-    int		len;
+    int		len = 0;
     char_u	*fbuf = NULL;
     char_u	buf[NUMBUFLEN];
 
@@ -1028,12 +1028,13 @@ f_fnamemodify(typval_T *argvars, typval_
 	return;
     fname = tv_get_string_chk(&argvars[0]);
     mods = tv_get_string_buf_chk(&argvars[1], buf);
-    if (fname == NULL)
+    if (mods == NULL || fname == NULL)
 	fname = NULL;
-    else if (mods != NULL && *mods != NUL)
+    else
     {
 	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;
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2136,
+/**/
     2135,
 /**/
     2134,