Fix warnings: window.c: win_close_othertab(): Np dereference: FP.

Problem    : Dereference of null pointer @ 1980.
Diagnostic : False positive.
Rationale  : I haven't been able to find the real reason why this is
             signaled. Nonetheless, I've been able to track down the
             introduction of this warning to commit
             77135447e0.
             The change there affecting this function is just a
             transformation maintaining semantics. So, this must be a
             FP, though I can't explain why.
             Analyzer thinks `win->w_buffer` can be null in line 1980,
             following an error path assuming win->w_buffer null at line
             1819. Given that `win_close` function was not modified by
             mentioned commit, I don't understand why this path is
             analyzed after the changes, but not before them. Or if it's
             analyzed, why it's discarded before changes but not after
             them. I don't see anything in changes to
             `close_last_window_tabpage` that should affect to
             being able to deduce `win->w_buffer` is not null.
Resolution : Assert buffer not null in `win_close_othertab`.
             Function comments state that passed window should have a
             buffer that can be hidden, which implies there should be a
             buffer.
             Reverting changes to `close_last_window_tabpage` in
             mentioned commit would be another way to fix this (tried
             and worked).
             But assert is preferred in this case because flat style
             reads better and we have some other way to fix it.
This commit is contained in:
Eliseo Martínez 2014-12-17 21:38:50 +01:00
parent 885661d25b
commit 5394796fd3

View File

@ -1977,6 +1977,7 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
tabpage_T *ptp = NULL;
int free_tp = FALSE;
assert(win->w_buffer); // to avoid np dereference warning in next line
if (win->w_closing || win->w_buffer->b_closing)
return; /* window is already being closed */