1
0
forked from aniani/vim

patch 7.4.2141

Problem:    Coverity reports bogus NULL check.
Solution:   When checking for a variable in the funccal scope don't pass the
            varname.
This commit is contained in:
Bram Moolenaar 2016-08-01 17:10:20 +02:00
parent acadbeabe1
commit ba96e9af38
4 changed files with 17 additions and 15 deletions

View File

@ -2838,7 +2838,7 @@ do_unlet(char_u *name, int forceit)
}
hi = hash_find(ht, varname);
if (HASHITEM_EMPTY(hi))
hi = find_hi_in_scoped_ht(name, &varname, &ht);
hi = find_hi_in_scoped_ht(name, &ht);
if (hi != NULL && !HASHITEM_EMPTY(hi))
{
di = HI2DI(hi);
@ -7344,8 +7344,7 @@ find_var(char_u *name, hashtab_T **htp, int no_autoload)
return ret;
/* Search in parent scope for lambda */
return find_var_in_scoped_ht(name, varname ? &varname : NULL,
no_autoload || htp != NULL);
return find_var_in_scoped_ht(name, no_autoload || htp != NULL);
}
/*
@ -7684,7 +7683,7 @@ set_var(
/* Search in parent scope which is possible to reference from lambda */
if (v == NULL)
v = find_var_in_scoped_ht(name, varname ? &varname : NULL, TRUE);
v = find_var_in_scoped_ht(name, TRUE);
if ((tv->v_type == VAR_FUNC || tv->v_type == VAR_PARTIAL)
&& var_check_func_name(name, v == NULL))

View File

@ -50,8 +50,8 @@ void *clear_current_funccal(void);
void restore_current_funccal(void *f);
void list_func_vars(int *first);
dict_T *get_current_funccal_dict(hashtab_T *ht);
hashitem_T *find_hi_in_scoped_ht(char_u *name, char_u **varname, hashtab_T **pht);
dictitem_T *find_var_in_scoped_ht(char_u *name, char_u **varname, int no_autoload);
hashitem_T *find_hi_in_scoped_ht(char_u *name, hashtab_T **pht);
dictitem_T *find_var_in_scoped_ht(char_u *name, int no_autoload);
int set_ref_in_previous_funccal(int copyID);
int set_ref_in_call_stack(int copyID);
int set_ref_in_func_args(int copyID);

View File

@ -3571,11 +3571,12 @@ get_current_funccal_dict(hashtab_T *ht)
* Search hashitem in parent scope.
*/
hashitem_T *
find_hi_in_scoped_ht(char_u *name, char_u **varname, hashtab_T **pht)
find_hi_in_scoped_ht(char_u *name, hashtab_T **pht)
{
funccall_T *old_current_funccal = current_funccal;
hashtab_T *ht;
hashitem_T *hi = NULL;
char_u *varname;
if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL)
return NULL;
@ -3584,10 +3585,10 @@ find_hi_in_scoped_ht(char_u *name, char_u **varname, hashtab_T **pht)
current_funccal = current_funccal->func->uf_scoped;
while (current_funccal != NULL)
{
ht = find_var_ht(name, varname);
if (ht != NULL && **varname != NUL)
ht = find_var_ht(name, &varname);
if (ht != NULL && *varname != NUL)
{
hi = hash_find(ht, *varname);
hi = hash_find(ht, varname);
if (!HASHITEM_EMPTY(hi))
{
*pht = ht;
@ -3607,11 +3608,12 @@ find_hi_in_scoped_ht(char_u *name, char_u **varname, hashtab_T **pht)
* Search variable in parent scope.
*/
dictitem_T *
find_var_in_scoped_ht(char_u *name, char_u **varname, int no_autoload)
find_var_in_scoped_ht(char_u *name, int no_autoload)
{
dictitem_T *v = NULL;
funccall_T *old_current_funccal = current_funccal;
hashtab_T *ht;
char_u *varname;
if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL)
return NULL;
@ -3620,11 +3622,10 @@ find_var_in_scoped_ht(char_u *name, char_u **varname, int no_autoload)
current_funccal = current_funccal->func->uf_scoped;
while (current_funccal)
{
ht = find_var_ht(name, varname ? &(*varname) : NULL);
if (ht != NULL)
ht = find_var_ht(name, &varname);
if (ht != NULL && *varname != NUL)
{
v = find_var_in_ht(ht, *name,
varname ? *varname : NULL, no_autoload);
v = find_var_in_ht(ht, *name, varname, no_autoload);
if (v != NULL)
break;
}

View File

@ -763,6 +763,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2141,
/**/
2140,
/**/