From 79fe9dedcfede1d2038b47a21f21a995051deaa2 Mon Sep 17 00:00:00 2001 From: Daniel Steinberg Date: Sun, 11 Jul 2021 00:32:37 -0400 Subject: window.c: address Coverity failure #14996 Check that `wip2` does not point to the same address as `wip`, to address the Coverity test failure from PR #14884. Based on the `if` clauses, `free_wininfo(wip2, ...)` is only called when `wip2->wi_win == NULL` and `wip->wi_win == wp`. I think `wip2` would only point to the same address as `wip` in scenarios where `wp` were `NULL`, which can be assumed otherwise based on the earlier code. --- src/nvim/window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index d051e8e467..d0bee83db1 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4666,7 +4666,8 @@ win_free ( // If there already is an entry with "wi_win" set to NULL it // must be removed, it would never be used. for (wip2 = buf->b_wininfo; wip2 != NULL; wip2 = wip2->wi_next) { - if (wip2->wi_win == NULL) { + // `wip2 != wip` to satisfy Coverity. #14884 + if (wip2 != wip && wip2->wi_win == NULL) { if (wip2->wi_next != NULL) { wip2->wi_next->wi_prev = wip2->wi_prev; } -- cgit