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.
Files: src/userfunc.c, src/proto/userfunc.pro, src/eval.c
*** ../vim-7.4.2140/src/userfunc.c 2016-08-01 16:29:42.516009792 +0200
--- src/userfunc.c 2016-08-01 17:07:48.890569129 +0200
***************
*** 3571,3581 ****
* Search hashitem in parent scope.
*/
hashitem_T *
! find_hi_in_scoped_ht(char_u *name, char_u **varname, hashtab_T **pht)
{
funccall_T *old_current_funccal = current_funccal;
hashtab_T *ht;
hashitem_T *hi = NULL;
if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL)
return NULL;
--- 3571,3582 ----
* Search hashitem in parent scope.
*/
hashitem_T *
! 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,3593 ****
current_funccal = current_funccal->func->uf_scoped;
while (current_funccal != NULL)
{
! ht = find_var_ht(name, varname);
! if (ht != NULL && **varname != NUL)
{
! hi = hash_find(ht, *varname);
if (!HASHITEM_EMPTY(hi))
{
*pht = ht;
--- 3585,3594 ----
current_funccal = current_funccal->func->uf_scoped;
while (current_funccal != NULL)
{
! ht = find_var_ht(name, &varname);
! if (ht != NULL && *varname != NUL)
{
! hi = hash_find(ht, varname);
if (!HASHITEM_EMPTY(hi))
{
*pht = ht;
***************
*** 3607,3617 ****
* Search variable in parent scope.
*/
dictitem_T *
! find_var_in_scoped_ht(char_u *name, char_u **varname, int no_autoload)
{
dictitem_T *v = NULL;
funccall_T *old_current_funccal = current_funccal;
hashtab_T *ht;
if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL)
return NULL;
--- 3608,3619 ----
* Search variable in parent scope.
*/
dictitem_T *
! 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,3630 ****
current_funccal = current_funccal->func->uf_scoped;
while (current_funccal)
{
! ht = find_var_ht(name, varname ? &(*varname) : NULL);
! if (ht != NULL)
{
! v = find_var_in_ht(ht, *name,
! varname ? *varname : NULL, no_autoload);
if (v != NULL)
break;
}
--- 3622,3631 ----
current_funccal = current_funccal->func->uf_scoped;
while (current_funccal)
{
! ht = find_var_ht(name, &varname);
! if (ht != NULL && *varname != NUL)
{
! v = find_var_in_ht(ht, *name, varname, no_autoload);
if (v != NULL)
break;
}
*** ../vim-7.4.2140/src/proto/userfunc.pro 2016-08-01 15:40:24.179878441
+0200
--- src/proto/userfunc.pro 2016-08-01 17:07:52.302537193 +0200
***************
*** 50,57 ****
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);
int set_ref_in_previous_funccal(int copyID);
int set_ref_in_call_stack(int copyID);
int set_ref_in_func_args(int copyID);
--- 50,57 ----
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, 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);
*** ../vim-7.4.2140/src/eval.c 2016-08-01 15:40:24.175878478 +0200
--- src/eval.c 2016-08-01 17:06:46.663151594 +0200
***************
*** 2838,2844 ****
}
hi = hash_find(ht, varname);
if (HASHITEM_EMPTY(hi))
! hi = find_hi_in_scoped_ht(name, &varname, &ht);
if (hi != NULL && !HASHITEM_EMPTY(hi))
{
di = HI2DI(hi);
--- 2838,2844 ----
}
hi = hash_find(ht, varname);
if (HASHITEM_EMPTY(hi))
! hi = find_hi_in_scoped_ht(name, &ht);
if (hi != NULL && !HASHITEM_EMPTY(hi))
{
di = HI2DI(hi);
***************
*** 7344,7351 ****
return ret;
/* Search in parent scope for lambda */
! return find_var_in_scoped_ht(name, varname ? &varname : NULL,
! no_autoload || htp != NULL);
}
/*
--- 7344,7350 ----
return ret;
/* Search in parent scope for lambda */
! return find_var_in_scoped_ht(name, no_autoload || htp != NULL);
}
/*
***************
*** 7684,7690 ****
/* 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);
if ((tv->v_type == VAR_FUNC || tv->v_type == VAR_PARTIAL)
&& var_check_func_name(name, v == NULL))
--- 7683,7689 ----
/* Search in parent scope which is possible to reference from lambda */
if (v == NULL)
! 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))
*** ../vim-7.4.2140/src/version.c 2016-08-01 16:35:56.472496015 +0200
--- src/version.c 2016-08-01 17:09:42.877502309 +0200
***************
*** 765,766 ****
--- 765,768 ----
{ /* Add new patch number below this line */
+ /**/
+ 2141,
/**/
--
A year spent in artificial intelligence is enough to make one
believe in God.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.