mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 20:06:33 +00:00
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:
@@ -1230,7 +1230,6 @@ static void win_rotate(int upwards, int count)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Check if all frames in this row/col have one window. */
|
/* Check if all frames in this row/col have one window. */
|
||||||
for (frp = curwin->w_frame->fr_parent->fr_child; frp != NULL;
|
for (frp = curwin->w_frame->fr_parent->fr_child; frp != NULL;
|
||||||
frp = frp->fr_next)
|
frp = frp->fr_next)
|
||||||
@@ -1246,6 +1245,7 @@ static void win_rotate(int upwards, int count)
|
|||||||
wp1 = frp->fr_win;
|
wp1 = frp->fr_win;
|
||||||
win_remove(wp1, NULL);
|
win_remove(wp1, NULL);
|
||||||
frame_remove(frp);
|
frame_remove(frp);
|
||||||
|
assert(frp->fr_parent->fr_child);
|
||||||
|
|
||||||
/* find last frame and append removed window/frame after it */
|
/* find last frame and append removed window/frame after it */
|
||||||
for (; frp->fr_next != NULL; frp = frp->fr_next)
|
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 */
|
wp2 = wp1->w_prev; /* will become last window */
|
||||||
win_remove(wp1, NULL);
|
win_remove(wp1, NULL);
|
||||||
frame_remove(frp);
|
frame_remove(frp);
|
||||||
|
assert(frp->fr_parent->fr_child);
|
||||||
|
|
||||||
/* append the removed window/frame before the first in the list */
|
/* append the removed window/frame before the first in the list */
|
||||||
win_append(frp->fr_parent->fr_child->fr_win->w_prev, wp1);
|
win_append(frp->fr_parent->fr_child->fr_win->w_prev, wp1);
|
||||||
|
Reference in New Issue
Block a user