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

Problem    : Dereference of null pointer @ 1268.
Diagnostic : False positive.
Rationale  : Suggested error path implies current window's frame to be
             the only child of its parent, which is ruled out by
             `if (firstwin == lastwin) {` check at the beginning.
Resolution : Assert another child remains after removing current frame.
             Strictly, assert is only needed in false branch of
             conditional, but we add it the same in the true branch to
             reduce reader surprise.
             Several forms of a single assert after
             `if (firstwin == lastwin) {` were tried, but analyzer
             cannot follow implications that way.
This commit is contained in:
Eliseo Martínez
2014-11-15 23:09:58 +01:00
parent b4ae878407
commit c802869e99

View File

@@ -1230,7 +1230,6 @@ static void win_rotate(int upwards, int count)
return;
}
/* Check if all frames in this row/col have one window. */
for (frp = curwin->w_frame->fr_parent->fr_child; frp != NULL;
frp = frp->fr_next)
@@ -1246,6 +1245,7 @@ static void win_rotate(int upwards, int count)
wp1 = frp->fr_win;
win_remove(wp1, NULL);
frame_remove(frp);
assert(frp->fr_parent->fr_child);
/* find last frame and append removed window/frame after it */
for (; frp->fr_next != NULL; frp = frp->fr_next)
@@ -1263,6 +1263,7 @@ static void win_rotate(int upwards, int count)
wp2 = wp1->w_prev; /* will become last window */
win_remove(wp1, NULL);
frame_remove(frp);
assert(frp->fr_parent->fr_child);
/* append the removed window/frame before the first in the list */
win_append(frp->fr_parent->fr_child->fr_win->w_prev, wp1);