From eb67f3a6ba52fd35edc8940a6e780a14bac75518 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 7 Oct 2025 01:17:46 -0400 Subject: [PATCH 1/3] vim-patch:8.2.5017: gcc 12.1 warns for uninitialized variable Problem: Gcc 12.1 warns for uninitialized variable. Solution: Initialize the variable. (closes vim/vim#10476) https://github.com/vim/vim/commit/8be36eecdc6728021f9c384c2305f114e671ec32 Co-authored-by: mityu --- src/nvim/eval/vars.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index c9816c72a1..8290926f4b 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1369,7 +1369,7 @@ static void tv_list_unlet_range(list_T *const l, listitem_T *const li_first, con int do_unlet(const char *const name, const size_t name_len, const bool forceit) FUNC_ATTR_NONNULL_ALL { - const char *varname; + const char *varname = NULL; // init to shut up gcc dict_T *dict; hashtab_T *ht = find_var_ht_dict(name, name_len, &varname, &dict); From 7995e7a89bfed790bd8ddc008f886993f17e1cce Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 10 Oct 2025 09:41:31 -0400 Subject: [PATCH 2/3] vim-patch:8.2.2456: Coverity warning for strcpy() into fixed size array Problem: Coverity warning for strcpy() into fixed size array. Solution: Add a type cast to hopefully silence the bogus warning. https://github.com/vim/vim/commit/7b6903f02c9eeb12cd85941ea0d352d84e4dab30 Co-authored-by: Bram Moolenaar --- src/nvim/eval/userfunc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 084d310035..51115b960b 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -281,7 +281,7 @@ static ufunc_T *alloc_ufunc(const char *name, size_t namelen) { size_t len = offsetof(ufunc_T, uf_name) + namelen + 1; ufunc_T *fp = xcalloc(1, len); - STRCPY(fp->uf_name, name); + xmemcpyz(fp->uf_name, name, namelen); fp->uf_namelen = namelen; if ((uint8_t)name[0] == K_SPECIAL) { From ffdb316491a177c8a7e9f9d269ad450db222c844 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 10 Oct 2025 20:56:42 -0400 Subject: [PATCH 3/3] vim-patch:8.2.4772: old Coverity warning for not checking ftell() return value Problem: Old Coverity warning for not checking ftell() return value. Solution: Check return value of fseek() and ftell(). https://github.com/vim/vim/commit/3df8f6e353eeaf24bb5fe3769ed07c03791bb58e Co-authored-by: Bram Moolenaar --- src/nvim/errors.h | 1 + src/nvim/main.c | 2 +- src/nvim/os/shell.c | 17 +++++++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/nvim/errors.h b/src/nvim/errors.h index 2ac837faae..e0fc9ec0ca 100644 --- a/src/nvim/errors.h +++ b/src/nvim/errors.h @@ -198,6 +198,7 @@ EXTERN const char e_failed_to_find_all_diff_anchors[] INIT( = N_("E1550: Failed EXTERN const char e_diff_anchors_with_hidden_windows[] INIT( = N_("E1562: Diff anchors cannot be used with hidden diff windows")); EXTERN const char e_trustfile[] INIT(= N_("E5570: Cannot update trust file: %s")); +EXTERN const char e_cannot_read_from_str_2[] INIT(= N_("E282: Cannot read from \"%s\"")); EXTERN const char e_unknown_option2[] INIT(= N_("E355: Unknown option: %s")); diff --git a/src/nvim/main.c b/src/nvim/main.c index 380e81dd69..a3da291bae 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -2143,7 +2143,7 @@ static void source_startup_scripts(const mparm_T *const parmp) // Do nothing. } else { if (do_source(parmp->use_vimrc, false, DOSO_NONE, NULL) != OK) { - semsg(_("E282: Cannot read from \"%s\""), parmp->use_vimrc); + semsg(_(e_cannot_read_from_str_2), parmp->use_vimrc); } } } else if (!silent_mode) { diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 46d2dc99c5..84882dbfc1 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -789,15 +789,20 @@ char *get_cmd_output(char *cmd, char *infile, int flags, size_t *ret_len) // read the names from the file into memory FILE *fd = os_fopen(tempname, READBIN); - if (fd == NULL) { - semsg(_(e_notopen), tempname); + // Not being able to seek means we can't read the file. + long len_l; + if (fd == NULL + || fseek(fd, 0L, SEEK_END) == -1 + || (len_l = ftell(fd)) == -1 // get size of temp file + || fseek(fd, 0L, SEEK_SET) == -1) { // back to the start + semsg(_(e_cannot_read_from_str_2), tempname); + if (fd != NULL) { + fclose(fd); + } goto done; } - fseek(fd, 0, SEEK_END); - size_t len = (size_t)ftell(fd); // get size of temp file - fseek(fd, 0, SEEK_SET); - + size_t len = (size_t)len_l; buffer = xmalloc(len + 1); size_t i = fread(buffer, 1, len, fd); fclose(fd);