Mercurial > vim
comparison src/userfunc.c @ 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 | 8436bb5134f5 |
children | 59565cdd7261 |
comparison
equal
deleted
inserted
replaced
9730:ba92bc887d14 | 9731:f85d94eee05b |
---|---|
3569 | 3569 |
3570 /* | 3570 /* |
3571 * Search hashitem in parent scope. | 3571 * Search hashitem in parent scope. |
3572 */ | 3572 */ |
3573 hashitem_T * | 3573 hashitem_T * |
3574 find_hi_in_scoped_ht(char_u *name, char_u **varname, hashtab_T **pht) | 3574 find_hi_in_scoped_ht(char_u *name, hashtab_T **pht) |
3575 { | 3575 { |
3576 funccall_T *old_current_funccal = current_funccal; | 3576 funccall_T *old_current_funccal = current_funccal; |
3577 hashtab_T *ht; | 3577 hashtab_T *ht; |
3578 hashitem_T *hi = NULL; | 3578 hashitem_T *hi = NULL; |
3579 char_u *varname; | |
3579 | 3580 |
3580 if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL) | 3581 if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL) |
3581 return NULL; | 3582 return NULL; |
3582 | 3583 |
3583 /* Search in parent scope which is possible to reference from lambda */ | 3584 /* Search in parent scope which is possible to reference from lambda */ |
3584 current_funccal = current_funccal->func->uf_scoped; | 3585 current_funccal = current_funccal->func->uf_scoped; |
3585 while (current_funccal != NULL) | 3586 while (current_funccal != NULL) |
3586 { | 3587 { |
3587 ht = find_var_ht(name, varname); | 3588 ht = find_var_ht(name, &varname); |
3588 if (ht != NULL && **varname != NUL) | 3589 if (ht != NULL && *varname != NUL) |
3589 { | 3590 { |
3590 hi = hash_find(ht, *varname); | 3591 hi = hash_find(ht, varname); |
3591 if (!HASHITEM_EMPTY(hi)) | 3592 if (!HASHITEM_EMPTY(hi)) |
3592 { | 3593 { |
3593 *pht = ht; | 3594 *pht = ht; |
3594 break; | 3595 break; |
3595 } | 3596 } |
3605 | 3606 |
3606 /* | 3607 /* |
3607 * Search variable in parent scope. | 3608 * Search variable in parent scope. |
3608 */ | 3609 */ |
3609 dictitem_T * | 3610 dictitem_T * |
3610 find_var_in_scoped_ht(char_u *name, char_u **varname, int no_autoload) | 3611 find_var_in_scoped_ht(char_u *name, int no_autoload) |
3611 { | 3612 { |
3612 dictitem_T *v = NULL; | 3613 dictitem_T *v = NULL; |
3613 funccall_T *old_current_funccal = current_funccal; | 3614 funccall_T *old_current_funccal = current_funccal; |
3614 hashtab_T *ht; | 3615 hashtab_T *ht; |
3616 char_u *varname; | |
3615 | 3617 |
3616 if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL) | 3618 if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL) |
3617 return NULL; | 3619 return NULL; |
3618 | 3620 |
3619 /* Search in parent scope which is possible to reference from lambda */ | 3621 /* Search in parent scope which is possible to reference from lambda */ |
3620 current_funccal = current_funccal->func->uf_scoped; | 3622 current_funccal = current_funccal->func->uf_scoped; |
3621 while (current_funccal) | 3623 while (current_funccal) |
3622 { | 3624 { |
3623 ht = find_var_ht(name, varname ? &(*varname) : NULL); | 3625 ht = find_var_ht(name, &varname); |
3624 if (ht != NULL) | 3626 if (ht != NULL && *varname != NUL) |
3625 { | 3627 { |
3626 v = find_var_in_ht(ht, *name, | 3628 v = find_var_in_ht(ht, *name, varname, no_autoload); |
3627 varname ? *varname : NULL, no_autoload); | |
3628 if (v != NULL) | 3629 if (v != NULL) |
3629 break; | 3630 break; |
3630 } | 3631 } |
3631 if (current_funccal == current_funccal->func->uf_scoped) | 3632 if (current_funccal == current_funccal->func->uf_scoped) |
3632 break; | 3633 break; |