tabpage_T *new_lu_tp = curtab;
+ // Stop Visual mode, the cursor and "VIsual" may very well be invalid after
+ // switching to another buffer.
+ reset_VIsual_and_resel();
+
// Try closing all windows that are not in the argument list.
// Also close windows that are not full width;
// When 'hidden' or "forceit" set the buffer becomes hidden.
gchar_pos(pos_T *pos)
{
char_u *ptr;
+ int ptrlen;
// When searching columns is sometimes put at the end of a line.
if (pos->col == MAXCOL)
return NUL;
+ ptrlen = ml_get_len(pos->lnum);
ptr = ml_get_pos(pos);
+ if (pos->col > ptrlen)
+ return NUL;
if (has_mbyte)
return (*mb_ptr2char)(ptr);
return (int)*ptr;
colnr_T startcol = 0, endcol = MAXCOL;
colnr_T cs, ce;
char_u *p;
+ int plen = ml_get_len(lnum);
p = ml_get(lnum);
bdp->startspaces = 0;
else
bdp->textlen = endcol - startcol + inclusive;
bdp->textcol = startcol;
- bdp->textstart = p + startcol;
+ bdp->textstart = startcol <= plen ? p + startcol : p;
}
/*
\ "\t{",
\ "\t}"], getline(1, '$'))
- close!
+ bw!
endfunc
" Test for 'p'ut in visual block mode
delmarks < >
call assert_fails('*yank', 'E20:')
- close!
+ bw!
endfunc
" Test for changing text in visual mode with 'exclusive' selection
call assert_equal('l one', getline(1))
set virtualedit&
set selection&
- close!
+ bw!
endfunc
" Test for starting linewise visual with a count.
8,9d
call cursor(5, 1)
call assert_beeps('normal ViBiB')
- close!
+ bw!
endfunc
func Test_visual_put_in_block()
set selection&vim
endfunc
+" the following caused a Heap-Overflow, because Vim was accessing outside of a
+" line end
+func Test_visual_pos_buffer_heap_overflow()
+ set virtualedit=all
+ args Xa Xb
+ all
+ call setline(1, ['', '', ''])
+ call cursor(3, 1)
+ wincmd w
+ call setline(1, 'foobar')
+ normal! $lv0
+ all
+ call setreg('"', 'baz')
+ normal! [P
+ set virtualedit=
+ bw! Xa Xb
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab