Compare commits

...

4 Commits

Author SHA1 Message Date
354796c19a patch 8.0.0356: leaking memory when setting 'ttytype'
Problem:    Leaking memory when setting 'ttytype'.
Solution:   Get free_oldval from the right option entry.
2017-02-23 17:18:37 +01:00
187a4f2814 patch 8.0.0355: using uninitialized memory when 'isfname' is empty
Problem:    Using uninitialized memory when 'isfname' is empty.
Solution:   Don't call getpwnam() without an argument. (Dominique Pelle,
            closes #1464)
2017-02-23 17:07:14 +01:00
1c410400fa patch 8.0.0354: test to check that setting termcap key fails sometimes
Problem:    Test to check that setting termcap key fails sometimes.
Solution:   Check for "t_k1" to exist. (Christian Brabandt, closes #1459)
2017-02-23 15:20:03 +01:00
3457d295f4 patch 8.0.0353: if [RO] is translated it may be truncated
Problem:    If [RO] in the status line is translated to a longer string, it is
            trunctted to 4 bytes.
Solution:   Skip over the resulting string. (Jente Hidskes, closes #1499)
2017-02-23 14:55:59 +01:00
6 changed files with 26 additions and 12 deletions

View File

@ -4028,15 +4028,12 @@ expand_env_esc(
*/ */
# if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H) # if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
{ {
struct passwd *pw;
/* Note: memory allocated by getpwnam() is never freed. /* Note: memory allocated by getpwnam() is never freed.
* Calling endpwent() apparently doesn't help. */ * Calling endpwent() apparently doesn't help. */
pw = getpwnam((char *)dst + 1); struct passwd *pw = (*dst == NUL)
if (pw != NULL) ? NULL : getpwnam((char *)dst + 1);
var = (char_u *)pw->pw_dir;
else var = (pw == NULL) ? NULL : (char_u *)pw->pw_dir;
var = NULL;
} }
if (var == NULL) if (var == NULL)
# endif # endif
@ -9652,7 +9649,7 @@ expand_wildcards(
# endif # endif
if (match_file_list(p_wig, (*files)[i], ffname)) if (match_file_list(p_wig, (*files)[i], ffname))
{ {
/* remove this matching files from the list */ /* remove this matching file from the list */
vim_free((*files)[i]); vim_free((*files)[i]);
for (j = i; j + 1 < *num_files; ++j) for (j = i; j + 1 < *num_files; ++j)
(*files)[j] = (*files)[j + 1]; (*files)[j] = (*files)[j + 1];
@ -10736,14 +10733,15 @@ has_env_var(char_u *p)
static int has_special_wildchar(char_u *p); static int has_special_wildchar(char_u *p);
/* /*
* Return TRUE if "p" contains a special wildcard character. * Return TRUE if "p" contains a special wildcard character, one that Vim
* Allowing for escaping. * cannot expand, requires using a shell.
*/ */
static int static int
has_special_wildchar(char_u *p) has_special_wildchar(char_u *p)
{ {
for ( ; *p; mb_ptr_adv(p)) for ( ; *p; mb_ptr_adv(p))
{ {
/* Allow for escaping. */
if (*p == '\\' && p[1] != NUL) if (*p == '\\' && p[1] != NUL)
++p; ++p;
else if (vim_strchr((char_u *)SPECIAL_WILDCHAR, *p) != NULL) else if (vim_strchr((char_u *)SPECIAL_WILDCHAR, *p) != NULL)

View File

@ -5936,6 +5936,7 @@ did_set_string_option(
/* Both 'term' and 'ttytype' point to T_NAME, only set the /* Both 'term' and 'ttytype' point to T_NAME, only set the
* P_ALLOCED flag on 'term'. */ * P_ALLOCED flag on 'term'. */
opt_idx = findoption((char_u *)"term"); opt_idx = findoption((char_u *)"term");
free_oldval = (options[opt_idx].flags & P_ALLOCED);
} }
} }

View File

@ -6730,7 +6730,7 @@ win_redr_status(win_T *wp)
if (wp->w_buffer->b_p_ro) if (wp->w_buffer->b_p_ro)
{ {
STRCPY(p + len, _("[RO]")); STRCPY(p + len, _("[RO]"));
len += 4; len += (int)STRLEN(p + len);
} }
this_ru_col = ru_col - (Columns - W_WIDTH(wp)); this_ru_col = ru_col - (Columns - W_WIDTH(wp));

View File

@ -15,7 +15,7 @@ func Test_let_termcap()
call assert_match('t_te.*^[[yes;', execute("set termcap")) call assert_match('t_te.*^[[yes;', execute("set termcap"))
let &t_te = old_t_te let &t_te = old_t_te
if !has('gui_running') if exists("+t_k1")
" Key code " Key code
let old_t_k1 = &t_k1 let old_t_k1 = &t_k1
let &t_k1 = "that" let &t_k1 = "that"

View File

@ -22,6 +22,13 @@ function! Test_whichwrap()
set whichwrap& set whichwrap&
endfunction endfunction
function! Test_isfname()
" This used to cause Vim to access uninitialized memory.
set isfname=
call assert_equal("~X", expand("~X"))
set isfname&
endfunction
function Test_options() function Test_options()
let caught = 'ok' let caught = 'ok'
try try

View File

@ -764,6 +764,14 @@ 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 */
/**/
356,
/**/
355,
/**/
354,
/**/
353,
/**/ /**/
352, 352,
/**/ /**/