Compare commits

...

2 Commits

Author SHA1 Message Date
Bram Moolenaar
de05bb2573 patch 8.2.4074: going over the end of NameBuff
Problem:    Going over the end of NameBuff.
Solution:   Check length when appending a space.
2022-01-13 13:08:14 +00:00
Bram Moolenaar
54598066ca patch 8.2.4073: Coverity warns for using NULL pointer
Problem:    Coverity warns for using NULL pointer.
Solution:   Bail out when running out of memory. Check for running over end of
            a string.
2022-01-13 12:05:09 +00:00
4 changed files with 28 additions and 8 deletions

View File

@@ -462,12 +462,13 @@ win_redr_status(win_T *wp, int ignore_pum UNUSED)
p = NameBuff;
len = (int)STRLEN(p);
if (bt_help(wp->w_buffer)
if ((bt_help(wp->w_buffer)
#ifdef FEAT_QUICKFIX
|| wp->w_p_pvw
|| wp->w_p_pvw
#endif
|| bufIsChanged(wp->w_buffer)
|| wp->w_buffer->b_p_ro)
|| bufIsChanged(wp->w_buffer)
|| wp->w_buffer->b_p_ro)
&& len < MAXPATHL - 1)
*(p + len++) = ' ';
if (bt_help(wp->w_buffer))
{

View File

@@ -2103,5 +2103,20 @@ func Test_edit_CTRL_hat()
bwipe!
endfunc
" Weird long file name was going over the end of NameBuff
func Test_edit_overlong_file_name()
CheckUnix
file 0000000000000000000000000000
file %%%%%%%%%%%%%%%%%%%%%%%%%%
file %%%%%%
set readonly
set ls=2
redraw!
set noreadonly ls&
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -1674,12 +1674,10 @@ deref_func_name(
void
emsg_funcname(char *ermsg, char_u *name)
{
char_u *p;
char_u *p = name;
if (*name == K_SPECIAL)
if (name[0] == K_SPECIAL && name[1] != NUL && name[2] != NUL)
p = concat_str((char_u *)"<SNR>", name + 3);
else
p = name;
semsg(_(ermsg), p);
if (p != name)
vim_free(p);
@@ -4154,6 +4152,8 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
else
eap->skip = TRUE;
}
if (name == NULL)
goto ret_free; // out of memory
// For "export def FuncName()" in an autoload script the function name
// is stored with the legacy autoload name "dir#script#FuncName" so

View File

@@ -750,6 +750,10 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4074,
/**/
4073,
/**/
4072,
/**/