changeset 9731:f85d94eee05b v7.4.2141

commit https://github.com/vim/vim/commit/ba96e9af388804364425185b47eed14988302865 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 1 17:10:20 2016 +0200 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.
author Christian Brabandt <cb@256bit.org>
date Mon, 01 Aug 2016 17:15:06 +0200
parents ba92bc887d14
children fe4bdbd102ea
files src/eval.c src/proto/userfunc.pro src/userfunc.c src/version.c
diffstat 4 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -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, 
 	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))
--- a/src/proto/userfunc.pro
+++ b/src/proto/userfunc.pro
@@ -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);
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -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_
     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_
  * 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
     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;
 	}
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2141,
+/**/
     2140,
 /**/
     2139,