Mercurial > vim
comparison src/ex_eval.c @ 22553:3ed3bed38e0f v8.2.1825
patch 8.2.1825: Vim9: accessing freed memory
Commit: https://github.com/vim/vim/commit/d747548c664815bb6e8520afa90b6108e1997591
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 10 20:31:37 2020 +0200
patch 8.2.1825: Vim9: accessing freed memory
Problem: Vim9: accessing freed memory.
Solution: Clear sv_name when the variable is deleted.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 10 Oct 2020 20:45:04 +0200 |
parents | 86a115a80262 |
children | 7d25264c246c |
comparison
equal
deleted
inserted
replaced
22552:0296c106ec8b | 22553:3ed3bed38e0f |
---|---|
923 { | 923 { |
924 int i; | 924 int i; |
925 | 925 |
926 if (in_vim9script()) | 926 if (in_vim9script()) |
927 { | 927 { |
928 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); | 928 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); |
929 | 929 hashtab_T *ht = get_script_local_ht(); |
930 for (i = cstack->cs_script_var_len[cstack->cs_idx]; | 930 |
931 if (ht != NULL) | |
932 { | |
933 for (i = cstack->cs_script_var_len[cstack->cs_idx]; | |
931 i < si->sn_var_vals.ga_len; ++i) | 934 i < si->sn_var_vals.ga_len; ++i) |
932 { | |
933 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + i; | |
934 hashtab_T *ht = get_script_local_ht(); | |
935 hashitem_T *hi; | |
936 | |
937 if (ht != NULL) | |
938 { | 935 { |
939 // Remove a variable declared inside the block, if it still | 936 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + i; |
940 // exists. | 937 hashitem_T *hi; |
941 hi = hash_find(ht, sv->sv_name); | 938 |
942 if (!HASHITEM_EMPTY(hi)) | 939 if (sv->sv_name != NULL) |
943 delete_var(ht, hi); | 940 { |
941 // Remove a variable declared inside the block, if it still | |
942 // exists. | |
943 hi = hash_find(ht, sv->sv_name); | |
944 if (!HASHITEM_EMPTY(hi)) | |
945 { | |
946 delete_var(ht, hi); | |
947 sv->sv_name = NULL; | |
948 } | |
949 } | |
944 } | 950 } |
945 } | 951 } |
946 } | 952 } |
947 --cstack->cs_idx; | 953 --cstack->cs_idx; |
948 } | 954 } |