patch 9.0.2107: [security]: FPE in adjust_plines_for_skipcol
Problem: [security]: FPE in adjust_plines_for_skipcol
Solution: don't divide by zero, return zero
Prevent a floating point exception when calculating w_skipcol (which can
happen with a small window when the number option is set and cpo+=n).
Add a test to verify
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/move.c b/src/move.c
index ce06dc3..fbb352a 100644
--- a/src/move.c
+++ b/src/move.c
@@ -45,8 +45,9 @@
return 0;
int width = wp->w_width - win_col_off(wp);
- if (wp->w_skipcol >= width)
- return (wp->w_skipcol - width) / (width + win_col_off2(wp)) + 1;
+ int w2 = width + win_col_off2(wp);
+ if (wp->w_skipcol >= width && w2 > 0)
+ return (wp->w_skipcol - width) / w2 + 1;
return 0;
}