forked from aniani/vim
patch 9.0.0947: invalid memory access in substitute with function
Problem: Invalid memory access in substitute with function that goes to another file. Solution: Check for text locked in CTRL-W gf.
This commit is contained in:
parent
ad85af5b38
commit
cc762a48d4
33
src/normal.c
33
src/normal.c
@ -188,13 +188,33 @@ check_text_locked(oparg_T *oap)
|
|||||||
{
|
{
|
||||||
if (text_locked())
|
if (text_locked())
|
||||||
{
|
{
|
||||||
clearopbeep(oap);
|
if (oap != NULL)
|
||||||
|
clearopbeep(oap);
|
||||||
text_locked_msg();
|
text_locked_msg();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If text is locked, "curbuf_lock" or "allbuf_lock" is set:
|
||||||
|
* Give an error message, possibly beep and return TRUE.
|
||||||
|
* "oap" may be NULL.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
check_text_or_curbuf_locked(oparg_T *oap)
|
||||||
|
{
|
||||||
|
if (check_text_locked(oap))
|
||||||
|
return TRUE;
|
||||||
|
if (curbuf_locked())
|
||||||
|
{
|
||||||
|
if (oap != NULL)
|
||||||
|
clearop(oap);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle the count before a normal command and set cap->count0.
|
* Handle the count before a normal command and set cap->count0.
|
||||||
*/
|
*/
|
||||||
@ -798,8 +818,7 @@ normal_cmd(
|
|||||||
goto normal_end;
|
goto normal_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((nv_cmds[idx].cmd_flags & NV_NCW)
|
if ((nv_cmds[idx].cmd_flags & NV_NCW) && check_text_or_curbuf_locked(oap))
|
||||||
&& (check_text_locked(oap) || curbuf_locked()))
|
|
||||||
// this command is not allowed now
|
// this command is not allowed now
|
||||||
goto normal_end;
|
goto normal_end;
|
||||||
|
|
||||||
@ -4026,13 +4045,9 @@ nv_gotofile(cmdarg_T *cap)
|
|||||||
char_u *ptr;
|
char_u *ptr;
|
||||||
linenr_T lnum = -1;
|
linenr_T lnum = -1;
|
||||||
|
|
||||||
if (check_text_locked(cap->oap))
|
if (check_text_or_curbuf_locked(cap->oap))
|
||||||
return;
|
return;
|
||||||
if (curbuf_locked())
|
|
||||||
{
|
|
||||||
clearop(cap->oap);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#ifdef FEAT_PROP_POPUP
|
#ifdef FEAT_PROP_POPUP
|
||||||
if (ERROR_IF_TERM_POPUP_WINDOW)
|
if (ERROR_IF_TERM_POPUP_WINDOW)
|
||||||
return;
|
return;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* normal.c */
|
/* normal.c */
|
||||||
|
int check_text_or_curbuf_locked(oparg_T *oap);
|
||||||
void normal_cmd(oparg_T *oap, int toplevel);
|
void normal_cmd(oparg_T *oap, int toplevel);
|
||||||
void check_visual_highlight(void);
|
void check_visual_highlight(void);
|
||||||
void end_visual_mode(void);
|
void end_visual_mode(void);
|
||||||
|
@ -1096,6 +1096,25 @@ func Test_sub_edit_scriptfile()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This was editing another file from the expression.
|
||||||
|
func Test_sub_expr_goto_other_file()
|
||||||
|
call writefile([''], 'Xfileone', 'D')
|
||||||
|
enew!
|
||||||
|
call setline(1, ['a', 'b', 'c', 'd',
|
||||||
|
\ 'Xfileone zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'])
|
||||||
|
|
||||||
|
func g:SplitGotoFile()
|
||||||
|
exe "sil! norm 0\<C-W>gf"
|
||||||
|
return ''
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
$
|
||||||
|
s/\%')/\=g:SplitGotoFile()
|
||||||
|
|
||||||
|
delfunc g:SplitGotoFile
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for the 2-letter and 3-letter :substitute commands
|
" Test for the 2-letter and 3-letter :substitute commands
|
||||||
func Test_substitute_short_cmd()
|
func Test_substitute_short_cmd()
|
||||||
new
|
new
|
||||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
947,
|
||||||
/**/
|
/**/
|
||||||
946,
|
946,
|
||||||
/**/
|
/**/
|
||||||
|
@ -567,6 +567,8 @@ newwindow:
|
|||||||
case Ctrl_F:
|
case Ctrl_F:
|
||||||
wingotofile:
|
wingotofile:
|
||||||
CHECK_CMDWIN;
|
CHECK_CMDWIN;
|
||||||
|
if (check_text_or_curbuf_locked(NULL))
|
||||||
|
break;
|
||||||
|
|
||||||
ptr = grab_file_name(Prenum1, &lnum);
|
ptr = grab_file_name(Prenum1, &lnum);
|
||||||
if (ptr != NULL)
|
if (ptr != NULL)
|
||||||
@ -885,7 +887,7 @@ win_split(int size, int flags)
|
|||||||
* When "new_wp" is NULL: split the current window in two.
|
* When "new_wp" is NULL: split the current window in two.
|
||||||
* When "new_wp" is not NULL: insert this window at the far
|
* When "new_wp" is not NULL: insert this window at the far
|
||||||
* top/left/right/bottom.
|
* top/left/right/bottom.
|
||||||
* return FAIL for failure, OK otherwise
|
* Return FAIL for failure, OK otherwise.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
win_split_ins(
|
win_split_ins(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user