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.
This commit is contained in:
Daniel Steinberg 2021-07-11 00:32:37 -04:00 committed by GitHub
parent 936f3a4ddc
commit 79fe9dedcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}