comparison src/if_ruby.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 425b686c5244
children d8e7d725a666
comparison
equal deleted inserted replaced
31230:e93800d75da2 31231:684e6dfa2fba
1797 1797
1798 di = dictitem_alloc((char_u *)RSTRING_PTR(rb_obj_as_string(key))); 1798 di = dictitem_alloc((char_u *)RSTRING_PTR(rb_obj_as_string(key)));
1799 if (di == NULL || ruby_convert_to_vim_value(val, &di->di_tv) != OK 1799 if (di == NULL || ruby_convert_to_vim_value(val, &di->di_tv) != OK
1800 || dict_add(d, di) != OK) 1800 || dict_add(d, di) != OK)
1801 { 1801 {
1802 d->dv_hashtab.ht_error = TRUE; 1802 d->dv_hashtab.ht_flags |= HTFLAGS_ERROR;
1803 return ST_STOP; 1803 return ST_STOP;
1804 } 1804 }
1805 return ST_CONTINUE; 1805 return ST_CONTINUE;
1806 } 1806 }
1807 1807
1877 d = dict_alloc(); 1877 d = dict_alloc();
1878 if (d == NULL) 1878 if (d == NULL)
1879 return FAIL; 1879 return FAIL;
1880 1880
1881 rb_hash_foreach(val, convert_hash2dict, (VALUE)d); 1881 rb_hash_foreach(val, convert_hash2dict, (VALUE)d);
1882 if (d->dv_hashtab.ht_error) 1882 if (d->dv_hashtab.ht_flags & HTFLAGS_ERROR)
1883 { 1883 {
1884 dict_unref(d); 1884 dict_unref(d);
1885 return FAIL; 1885 return FAIL;
1886 } 1886 }
1887 1887