comparison src/evalvars.c @ 17944:745c02392844 v8.1.1968

patch 8.1.1968: crash when using nested map() Commit: https://github.com/vim/vim/commit/27da7de7c547dbf983ed7dd901ea59be4e7c9ab2 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 3 17:13:37 2019 +0200 patch 8.1.1968: crash when using nested map() Problem: Crash when using nested map(). Solution: Clear the pointer in prepare_vimvar(). (Ozaki Kiichi, closes #4890, closes #4891)
author Bram Moolenaar <Bram@vim.org>
date Tue, 03 Sep 2019 17:15:03 +0200
parents 4d63d47d87ef
children 5c8906f653f5
comparison
equal deleted inserted replaced
17943:7c6b79acf9b9 17944:745c02392844
487 } 487 }
488 #endif 488 #endif
489 489
490 /* 490 /*
491 * Prepare v: variable "idx" to be used. 491 * Prepare v: variable "idx" to be used.
492 * Save the current typeval in "save_tv". 492 * Save the current typeval in "save_tv" and clear it.
493 * When not used yet add the variable to the v: hashtable. 493 * When not used yet add the variable to the v: hashtable.
494 */ 494 */
495 void 495 void
496 prepare_vimvar(int idx, typval_T *save_tv) 496 prepare_vimvar(int idx, typval_T *save_tv)
497 { 497 {
498 *save_tv = vimvars[idx].vv_tv; 498 *save_tv = vimvars[idx].vv_tv;
499 vimvars[idx].vv_str = NULL; // don't free it now
499 if (vimvars[idx].vv_type == VAR_UNKNOWN) 500 if (vimvars[idx].vv_type == VAR_UNKNOWN)
500 hash_add(&vimvarht, vimvars[idx].vv_di.di_key); 501 hash_add(&vimvarht, vimvars[idx].vv_di.di_key);
501 } 502 }
502 503
503 /* 504 /*
504 * Restore v: variable "idx" to typeval "save_tv". 505 * Restore v: variable "idx" to typeval "save_tv".
506 * Note that the v: variable must have been cleared already.
505 * When no longer defined, remove the variable from the v: hashtable. 507 * When no longer defined, remove the variable from the v: hashtable.
506 */ 508 */
507 void 509 void
508 restore_vimvar(int idx, typval_T *save_tv) 510 restore_vimvar(int idx, typval_T *save_tv)
509 { 511 {