From 6f49ed58c3d87ed8632ac84822173811a1a6ee3f Mon Sep 17 00:00:00 2001 From: Daniil Zhukov Date: Fri, 26 Jan 2024 23:36:48 +0400 Subject: fix(coverity/348240): memory leak in put_view() --- src/nvim/ex_session.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 3e15641be8..fb37bc86f1 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -366,6 +366,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr if (put_line(fd, "enew | setl bt=help") == FAIL || fprintf(fd, "help %s", curtag) < 0 || put_eol(fd) == FAIL) { + xfree(fname_esc); return FAIL; } } else if (wp->w_buffer->b_ffname != NULL -- cgit From 9d48266bed96d3ed9c7edf45e3b5fb8a9d0fda87 Mon Sep 17 00:00:00 2001 From: Daniil Zhukov Date: Sat, 27 Jan 2024 23:00:24 +0400 Subject: fix(coverity/471380): null dereference in get_local_additions() strrchr returns null pointer if '.' is not present in file name. Notice that filenames are filtered to match "doc/*.??[tx]" pattern earlier so we shouldn't expect null pointer here. However later in code strrchr return value is checked so it seems better and more consistent to do the same here too. --- src/nvim/help.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/help.c b/src/nvim/help.c index c6a6108010..879e2801a7 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -701,6 +701,9 @@ void get_local_additions(void) const char *const f1 = fnames[i1]; const char *const t1 = path_tail(f1); const char *const e1 = strrchr(t1, '.'); + if (e1 == NULL) { + continue; + } if (path_fnamecmp(e1, ".txt") != 0 && path_fnamecmp(e1, fname + 4) != 0) { // Not .txt and not .abx, remove it. @@ -715,7 +718,7 @@ void get_local_additions(void) } const char *const t2 = path_tail(f2); const char *const e2 = strrchr(t2, '.'); - if (e1 == NULL || e2 == NULL) { + if (e2 == NULL) { continue; } if (e1 - f1 != e2 - f2 -- cgit