clang/"null pointer dereference": close_buffer

False positive: win_valid_any_tab() already checks `win != NULL`.
This commit is contained in:
Justin M. Keyes 2019-01-13 17:47:14 +01:00
parent 1ec0b9204b
commit 4cba75dab0

View File

@ -447,7 +447,8 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
return;
}
if (win_valid_any_tab(win)) {
if (win != NULL // Avoid bogus clang warning.
&& win_valid_any_tab(win)) {
// Set b_last_cursor when closing the last window for the buffer.
// Remember the last cursor position and window options of the buffer.
// This used to be only for the current window, but then options like
@ -575,7 +576,9 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
if (buf == curbuf && !is_curbuf)
return;
if (win_valid_any_tab(win) && win->w_buffer == buf) {
if (win != NULL // Avoid bogus clang warning.
&& win_valid_any_tab(win)
&& win->w_buffer == buf) {
win->w_buffer = NULL; // make sure we don't use the buffer now
}