mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.0540: assigning stack variable to argument confuses Coverity
Problem: Assigning stack variable to argument confuses Coverity. Solution: Use a local pointer, also makes the code simpler.
This commit is contained in:
parent
21d393a12b
commit
6f98114e4a
50
src/option.c
50
src/option.c
@ -1220,7 +1220,7 @@ typedef enum {
|
|||||||
do_set_string(
|
do_set_string(
|
||||||
int opt_idx,
|
int opt_idx,
|
||||||
int opt_flags,
|
int opt_flags,
|
||||||
char_u **arg,
|
char_u **argp,
|
||||||
int nextchar,
|
int nextchar,
|
||||||
set_op_T op_arg,
|
set_op_T op_arg,
|
||||||
int flags,
|
int flags,
|
||||||
@ -1230,6 +1230,7 @@ do_set_string(
|
|||||||
int *value_checked,
|
int *value_checked,
|
||||||
char **errmsg)
|
char **errmsg)
|
||||||
{
|
{
|
||||||
|
char_u *arg = *argp;
|
||||||
set_op_T op = op_arg;
|
set_op_T op = op_arg;
|
||||||
char_u *varp = varp_arg;
|
char_u *varp = varp_arg;
|
||||||
char_u *save_arg = NULL;
|
char_u *save_arg = NULL;
|
||||||
@ -1317,18 +1318,18 @@ do_set_string(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++*arg; // jump to after the '=' or ':'
|
++arg; // jump to after the '=' or ':'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set 'keywordprg' to ":help" if an empty
|
* Set 'keywordprg' to ":help" if an empty
|
||||||
* value was passed to :set by the user.
|
* value was passed to :set by the user.
|
||||||
* Misuse errbuf[] for the resulting string.
|
* Misuse errbuf[] for the resulting string.
|
||||||
*/
|
*/
|
||||||
if (varp == (char_u *)&p_kp && (**arg == NUL || **arg == ' '))
|
if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' '))
|
||||||
{
|
{
|
||||||
STRCPY(errbuf, ":help");
|
STRCPY(errbuf, ":help");
|
||||||
save_arg = *arg;
|
save_arg = arg;
|
||||||
*arg = (char_u *)errbuf;
|
arg = (char_u *)errbuf;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Convert 'backspace' number to string, for
|
* Convert 'backspace' number to string, for
|
||||||
@ -1368,10 +1369,10 @@ do_set_string(
|
|||||||
* Convert 'whichwrap' number to string, for backwards compatibility
|
* Convert 'whichwrap' number to string, for backwards compatibility
|
||||||
* with Vim 3.0.
|
* with Vim 3.0.
|
||||||
*/
|
*/
|
||||||
else if (varp == (char_u *)&p_ww && VIM_ISDIGIT(**arg))
|
else if (varp == (char_u *)&p_ww && VIM_ISDIGIT(*arg))
|
||||||
{
|
{
|
||||||
*whichwrap = NUL;
|
*whichwrap = NUL;
|
||||||
int i = getdigits(arg);
|
int i = getdigits(&arg);
|
||||||
if (i & 1)
|
if (i & 1)
|
||||||
STRCAT(whichwrap, "b,");
|
STRCAT(whichwrap, "b,");
|
||||||
if (i & 2)
|
if (i & 2)
|
||||||
@ -1384,16 +1385,16 @@ do_set_string(
|
|||||||
STRCAT(whichwrap, "[,],");
|
STRCAT(whichwrap, "[,],");
|
||||||
if (*whichwrap != NUL) // remove trailing ,
|
if (*whichwrap != NUL) // remove trailing ,
|
||||||
whichwrap[STRLEN(whichwrap) - 1] = NUL;
|
whichwrap[STRLEN(whichwrap) - 1] = NUL;
|
||||||
save_arg = *arg;
|
save_arg = arg;
|
||||||
*arg = (char_u *)whichwrap;
|
arg = (char_u *)whichwrap;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Remove '>' before 'dir' and 'bdir', for backwards compatibility with
|
* Remove '>' before 'dir' and 'bdir', for backwards compatibility with
|
||||||
* version 3.0
|
* version 3.0
|
||||||
*/
|
*/
|
||||||
else if ( **arg == '>' && (varp == (char_u *)&p_dir
|
else if (*arg == '>' && (varp == (char_u *)&p_dir
|
||||||
|| varp == (char_u *)&p_bdir))
|
|| varp == (char_u *)&p_bdir))
|
||||||
++*arg;
|
++arg;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy the new string into allocated memory.
|
* Copy the new string into allocated memory.
|
||||||
@ -1401,7 +1402,7 @@ do_set_string(
|
|||||||
* backslashes.
|
* backslashes.
|
||||||
*/
|
*/
|
||||||
// get a bit too much
|
// get a bit too much
|
||||||
newlen = (unsigned)STRLEN(*arg) + 1;
|
newlen = (unsigned)STRLEN(arg) + 1;
|
||||||
if (op != OP_NONE)
|
if (op != OP_NONE)
|
||||||
newlen += (unsigned)STRLEN(origval) + 1;
|
newlen += (unsigned)STRLEN(origval) + 1;
|
||||||
newval = alloc(newlen);
|
newval = alloc(newlen);
|
||||||
@ -1416,29 +1417,29 @@ do_set_string(
|
|||||||
* but do remove it for "\\\\machine\\path".
|
* but do remove it for "\\\\machine\\path".
|
||||||
* The reverse is found in ExpandOldSetting().
|
* The reverse is found in ExpandOldSetting().
|
||||||
*/
|
*/
|
||||||
while (**arg && !VIM_ISWHITE(**arg))
|
while (*arg && !VIM_ISWHITE(*arg))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (**arg == '\\' && (*arg)[1] != NUL
|
if (*arg == '\\' && arg[1] != NUL
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
&& !((flags & P_EXPAND)
|
&& !((flags & P_EXPAND)
|
||||||
&& vim_isfilec((*arg)[1])
|
&& vim_isfilec(arg[1])
|
||||||
&& !VIM_ISWHITE((*arg)[1])
|
&& !VIM_ISWHITE(arg[1])
|
||||||
&& ((*arg)[1] != '\\'
|
&& (arg[1] != '\\'
|
||||||
|| (s == newval && (*arg)[2] != '\\')))
|
|| (s == newval && arg[2] != '\\')))
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
++*arg; // remove backslash
|
++arg; // remove backslash
|
||||||
if (has_mbyte && (i = (*mb_ptr2len)(*arg)) > 1)
|
if (has_mbyte && (i = (*mb_ptr2len)(arg)) > 1)
|
||||||
{
|
{
|
||||||
// copy multibyte char
|
// copy multibyte char
|
||||||
mch_memmove(s, *arg, (size_t)i);
|
mch_memmove(s, arg, (size_t)i);
|
||||||
*arg += i;
|
arg += i;
|
||||||
s += i;
|
s += i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*s++ = *(*arg)++;
|
*s++ = *arg++;
|
||||||
}
|
}
|
||||||
*s = NUL;
|
*s = NUL;
|
||||||
|
|
||||||
@ -1565,7 +1566,7 @@ do_set_string(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (save_arg != NULL) // number for 'whichwrap'
|
if (save_arg != NULL) // number for 'whichwrap'
|
||||||
*arg = save_arg;
|
arg = save_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1627,6 +1628,7 @@ do_set_string(
|
|||||||
vim_free(saved_newval);
|
vim_free(saved_newval);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
*argp = arg;
|
||||||
return *errmsg == NULL ? OK : FAIL;
|
return *errmsg == NULL ? OK : FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,6 +699,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 */
|
||||||
|
/**/
|
||||||
|
540,
|
||||||
/**/
|
/**/
|
||||||
539,
|
539,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user