Mercurial > vim
comparison src/eval.c @ 7852:8818755d8326 v7.4.1223
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 31 16:28:04 2016 +0100
patch 7.4.1223
Problem: Crash when setting v:errors to a number.
Solution: Free the typval without assuming its type. (Yasuhiro Matsumoto)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 31 Jan 2016 16:30:04 +0100 |
parents | 10f17a228661 |
children | 226ed297307f |
comparison
equal
deleted
inserted
replaced
7851:ed080aca141b | 7852:8818755d8326 |
---|---|
917 hash_add(&vimvarht, p->vv_di.di_key); | 917 hash_add(&vimvarht, p->vv_di.di_key); |
918 if (p->vv_flags & VV_COMPAT) | 918 if (p->vv_flags & VV_COMPAT) |
919 /* add to compat scope dict */ | 919 /* add to compat scope dict */ |
920 hash_add(&compat_hashtab, p->vv_di.di_key); | 920 hash_add(&compat_hashtab, p->vv_di.di_key); |
921 } | 921 } |
922 vimvars[VV_VERSION].vv_nr = VIM_VERSION_100; | |
923 | |
922 set_vim_var_nr(VV_SEARCHFORWARD, 1L); | 924 set_vim_var_nr(VV_SEARCHFORWARD, 1L); |
923 set_vim_var_nr(VV_HLSEARCH, 1L); | 925 set_vim_var_nr(VV_HLSEARCH, 1L); |
924 set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc()); | 926 set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc()); |
925 set_vim_var_list(VV_ERRORS, list_alloc()); | 927 set_vim_var_list(VV_ERRORS, list_alloc()); |
926 | 928 |
20614 set_vim_var_string( | 20616 set_vim_var_string( |
20615 int idx, | 20617 int idx, |
20616 char_u *val, | 20618 char_u *val, |
20617 int len) /* length of "val" to use or -1 (whole string) */ | 20619 int len) /* length of "val" to use or -1 (whole string) */ |
20618 { | 20620 { |
20619 /* Need to do this (at least) once, since we can't initialize a union. | 20621 clear_tv(&vimvars[idx].vv_di.di_tv); |
20620 * Will always be invoked when "v:progname" is set. */ | 20622 vimvars[idx].vv_type = VAR_STRING; |
20621 vimvars[VV_VERSION].vv_nr = VIM_VERSION_100; | |
20622 | |
20623 vim_free(vimvars[idx].vv_str); | |
20624 if (val == NULL) | 20623 if (val == NULL) |
20625 vimvars[idx].vv_str = NULL; | 20624 vimvars[idx].vv_str = NULL; |
20626 else if (len == -1) | 20625 else if (len == -1) |
20627 vimvars[idx].vv_str = vim_strsave(val); | 20626 vimvars[idx].vv_str = vim_strsave(val); |
20628 else | 20627 else |
20633 * Set List v: variable to "val". | 20632 * Set List v: variable to "val". |
20634 */ | 20633 */ |
20635 void | 20634 void |
20636 set_vim_var_list(int idx, list_T *val) | 20635 set_vim_var_list(int idx, list_T *val) |
20637 { | 20636 { |
20638 list_unref(vimvars[idx].vv_list); | 20637 clear_tv(&vimvars[idx].vv_di.di_tv); |
20638 vimvars[idx].vv_type = VAR_LIST; | |
20639 vimvars[idx].vv_list = val; | 20639 vimvars[idx].vv_list = val; |
20640 if (val != NULL) | 20640 if (val != NULL) |
20641 ++val->lv_refcount; | 20641 ++val->lv_refcount; |
20642 } | 20642 } |
20643 | 20643 |
20648 set_vim_var_dict(int idx, dict_T *val) | 20648 set_vim_var_dict(int idx, dict_T *val) |
20649 { | 20649 { |
20650 int todo; | 20650 int todo; |
20651 hashitem_T *hi; | 20651 hashitem_T *hi; |
20652 | 20652 |
20653 dict_unref(vimvars[idx].vv_dict); | 20653 clear_tv(&vimvars[idx].vv_di.di_tv); |
20654 vimvars[idx].vv_type = VAR_DICT; | |
20654 vimvars[idx].vv_dict = val; | 20655 vimvars[idx].vv_dict = val; |
20655 if (val != NULL) | 20656 if (val != NULL) |
20656 { | 20657 { |
20657 ++val->dv_refcount; | 20658 ++val->dv_refcount; |
20658 | 20659 |