mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 17:06:30 +00:00
vim-patch:9.0.2107: [security]: FPE in adjust_plines_for_skipcol (#26082)
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
cb0b99f067
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@@ -83,18 +83,18 @@ int linetabsize_col(int startcol, char *s)
|
||||
/// @param len
|
||||
///
|
||||
/// @return Number of characters the string will take on the screen.
|
||||
unsigned win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len)
|
||||
int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len)
|
||||
{
|
||||
chartabsize_T cts;
|
||||
init_chartabsize_arg(&cts, wp, lnum, 0, line, line);
|
||||
win_linetabsize_cts(&cts, len);
|
||||
clear_chartabsize_arg(&cts);
|
||||
return (unsigned)cts.cts_vcol;
|
||||
return cts.cts_vcol;
|
||||
}
|
||||
|
||||
/// Return the number of cells line "lnum" of window "wp" will take on the
|
||||
/// screen, taking into account the size of a tab and inline virtual text.
|
||||
unsigned linetabsize(win_T *wp, linenr_T lnum)
|
||||
int linetabsize(win_T *wp, linenr_T lnum)
|
||||
{
|
||||
return win_linetabsize(wp, lnum, ml_get_buf(wp->w_buffer, lnum), (colnr_T)MAXCOL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user