Permalink
Browse files

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.
  • Loading branch information...
1 parent acadbea commit ba96e9af388804364425185b47eed14988302865 @brammool brammool committed Aug 1, 2016
Showing with 17 additions and 15 deletions.
  1. +3 −4 src/eval.c
  2. +2 −2 src/proto/userfunc.pro
  3. +10 −9 src/userfunc.c
  4. +2 −0 src/version.c
View
@@ -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))
@@ -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
@@ -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
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2141,
+/**/
2140,
/**/
2139,

0 comments on commit ba96e9a

Please sign in to comment.