Mercurial > vim
comparison src/vim9script.c @ 31231:684e6dfa2fba v9.0.0949
patch 9.0.0949: crash when unletting a variable while listing variables
Commit: https://github.com/vim/vim/commit/ef2c325f5e3c437b722bb96bf369ba2a5c541163
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Nov 25 16:31:51 2022 +0000
patch 9.0.0949: crash when unletting a variable while listing variables
Problem: Crash when unletting a variable while listing variables.
Solution: Disallow changing a hashtable while going over the entries.
(closes #11435)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 25 Nov 2022 17:45:04 +0100 |
parents | 12e6c7bae2a9 |
children | 307f68a41b03 |
comparison
equal
deleted
inserted
replaced
31230:e93800d75da2 | 31231:684e6dfa2fba |
---|---|
940 newsav->sav_di = di; | 940 newsav->sav_di = di; |
941 newsav->sav_block_id = si->sn_current_block_id; | 941 newsav->sav_block_id = si->sn_current_block_id; |
942 | 942 |
943 if (HASHITEM_EMPTY(hi)) | 943 if (HASHITEM_EMPTY(hi)) |
944 // new variable name | 944 // new variable name |
945 hash_add(&si->sn_all_vars.dv_hashtab, newsav->sav_key); | 945 hash_add(&si->sn_all_vars.dv_hashtab, newsav->sav_key, |
946 "add variable"); | |
946 else if (sav != NULL) | 947 else if (sav != NULL) |
947 // existing name in a new block, append to the list | 948 // existing name in a new block, append to the list |
948 sav->sav_next = newsav; | 949 sav->sav_next = newsav; |
949 } | 950 } |
950 } | 951 } |
1031 sv->sv_tv = &sav->sav_tv; | 1032 sv->sv_tv = &sav->sav_tv; |
1032 } | 1033 } |
1033 else | 1034 else |
1034 { | 1035 { |
1035 if (sav_prev == NULL) | 1036 if (sav_prev == NULL) |
1036 hash_remove(all_ht, all_hi); | 1037 hash_remove(all_ht, all_hi, "hide variable"); |
1037 else | 1038 else |
1038 sav_prev->sav_next = sav->sav_next; | 1039 sav_prev->sav_next = sav->sav_next; |
1039 sv->sv_name = NULL; | 1040 sv->sv_name = NULL; |
1040 vim_free(sav); | 1041 vim_free(sav); |
1041 } | 1042 } |