diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-13 12:25:35 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-13 12:25:35 +0100 |
commit | c530852315517a44354edbbd6c3375355bbec37e (patch) | |
tree | e2595fe0da14d607e3ec811a23f8b91f1dfb848b /src/filepath.c | |
parent | 93f82cbee515e13b564f51ddcd5e3d6694358ba4 (diff) |
patch 8.2.2136: Vim9: Using uninitialized variablev8.2.2136
Problem: Vim9: Using uninitialized variable.
Solution: Initialize "len" to zero. Clean up fnamemodify().
Diffstat (limited to 'src/filepath.c')
-rw-r--r-- | src/filepath.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/filepath.c b/src/filepath.c index 347612a802..0db0dcfb1f 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -1019,7 +1019,7 @@ f_fnamemodify(typval_T *argvars, typval_T *rettv) 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_T *rettv) 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; |