vim-patch:8.1.1642: may use uninitialized variable

Problem:    May use uninitialized variable. (Patrick Palka)
Solution:   Initialize variables earlier. (closes vim/vim#4623)
ec572ad6a6
This commit is contained in:
Jan Edmund Lazo
2020-02-23 18:28:11 -05:00
parent a78e8f6e1b
commit ab38df2fc5
3 changed files with 29 additions and 18 deletions

View File

@@ -412,9 +412,9 @@ EXTERN vimmenu_T *root_menu INIT(= NULL);
*/ */
EXTERN int sys_menu INIT(= FALSE); EXTERN int sys_menu INIT(= FALSE);
/* While redrawing the screen this flag is set. It means the screen size // While redrawing the screen this flag is set. It means the screen size
* ('lines' and 'rows') must not be changed. */ // ('lines' and 'rows') must not be changed.
EXTERN int updating_screen INIT(= FALSE); EXTERN int updating_screen INIT(= 0);
/* /*
* All windows are linked in a list. firstwin points to the first entry, * All windows are linked in a list. firstwin points to the first entry,

View File

@@ -334,10 +334,10 @@ int update_screen(int type)
} }
return FAIL; return FAIL;
} }
updating_screen = 1;
updating_screen = TRUE; display_tick++; // let syntax code know we're in a next round of
++display_tick; /* let syntax code know we're in a next round of // display updating
* display updating */
// Tricky: vim code can reset msg_scrolled behind our back, so need // Tricky: vim code can reset msg_scrolled behind our back, so need
// separate bookkeeping for now. // separate bookkeeping for now.
@@ -565,7 +565,7 @@ int update_screen(int type)
wp->w_buffer->b_mod_set = false; wp->w_buffer->b_mod_set = false;
} }
updating_screen = FALSE; updating_screen = 0;
/* Clear or redraw the command line. Done last, because scrolling may /* Clear or redraw the command line. Done last, because scrolling may
* mess up the command line. */ * mess up the command line. */
@@ -2215,9 +2215,10 @@ win_line (
int n_skip = 0; /* nr of chars to skip for 'nowrap' */ int n_skip = 0; /* nr of chars to skip for 'nowrap' */
int fromcol = 0, tocol = 0; // start/end of inverting int fromcol = -10; // start of inverting
int tocol = MAXCOL; // end of inverting
int fromcol_prev = -2; // start of inverting after cursor int fromcol_prev = -2; // start of inverting after cursor
int noinvcur = false; // don't invert the cursor bool noinvcur = false; // don't invert the cursor
pos_T *top, *bot; pos_T *top, *bot;
int lnum_in_visual_area = false; int lnum_in_visual_area = false;
pos_T pos; pos_T pos;
@@ -2416,27 +2417,26 @@ win_line (
capcol_lnum = 0; capcol_lnum = 0;
} }
// // handle Visual active in this window
// handle visual active in this window
//
fromcol = -10;
tocol = MAXCOL;
if (VIsual_active && wp->w_buffer == curwin->w_buffer) { if (VIsual_active && wp->w_buffer == curwin->w_buffer) {
// Visual is after curwin->w_cursor
if (ltoreq(curwin->w_cursor, VIsual)) { if (ltoreq(curwin->w_cursor, VIsual)) {
// Visual is after curwin->w_cursor
top = &curwin->w_cursor; top = &curwin->w_cursor;
bot = &VIsual; bot = &VIsual;
} else { // Visual is before curwin->w_cursor } else {
// Visual is before curwin->w_cursor
top = &VIsual; top = &VIsual;
bot = &curwin->w_cursor; bot = &curwin->w_cursor;
} }
lnum_in_visual_area = (lnum >= top->lnum && lnum <= bot->lnum); lnum_in_visual_area = (lnum >= top->lnum && lnum <= bot->lnum);
if (VIsual_mode == Ctrl_V) { // block mode if (VIsual_mode == Ctrl_V) {
// block mode
if (lnum_in_visual_area) { if (lnum_in_visual_area) {
fromcol = wp->w_old_cursor_fcol; fromcol = wp->w_old_cursor_fcol;
tocol = wp->w_old_cursor_lcol; tocol = wp->w_old_cursor_lcol;
} }
} else { // non-block mode } else {
// non-block mode
if (lnum > top->lnum && lnum <= bot->lnum) { if (lnum > top->lnum && lnum <= bot->lnum) {
fromcol = 0; fromcol = 0;
} else if (lnum == top->lnum) { } else if (lnum == top->lnum) {

View File

@@ -252,3 +252,14 @@ func Test_numberwidth_adjusted()
call s:compare_lines(expect, lines) call s:compare_lines(expect, lines)
call s:close_windows() call s:close_windows()
endfunc endfunc
" This was causing a memcheck error
func Test_relativenumber_uninitialised()
new
set rnu
call setline(1, ["a", "b"])
redraw
call feedkeys("j", 'xt')
redraw
bwipe!
endfunc