vim-patch:7.4.525 #1988

Problem:    map() leaks memory when there is an error in the expression.
Solution:   Call clear_tv(). (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-525
This commit is contained in:
Fabian Brosda
2015-02-14 16:48:53 +01:00
committed by Justin M. Keyes
parent 866da6d65e
commit 0a7cd65cbc
2 changed files with 5 additions and 4 deletions

View File

@@ -8575,12 +8575,12 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map)
(char_u *)_(arg_errmsg))) (char_u *)_(arg_errmsg)))
break; break;
vimvars[VV_KEY].vv_str = vim_strsave(di->di_key); vimvars[VV_KEY].vv_str = vim_strsave(di->di_key);
if (filter_map_one(&di->di_tv, expr, map, &rem) == FAIL int r = filter_map_one(&di->di_tv, expr, map, &rem);
|| did_emsg) clear_tv(&vimvars[VV_KEY].vv_tv);
if (r == FAIL || did_emsg)
break; break;
if (!map && rem) if (!map && rem)
dictitem_remove(d, di); dictitem_remove(d, di);
clear_tv(&vimvars[VV_KEY].vv_tv);
} }
} }
hash_unlock(ht); hash_unlock(ht);
@@ -8622,6 +8622,7 @@ static int filter_map_one(typval_T *tv, char_u *expr, int map, int *remp)
goto theend; goto theend;
if (*s != NUL) { /* check for trailing chars after expr */ if (*s != NUL) { /* check for trailing chars after expr */
EMSG2(_(e_invexpr2), s); EMSG2(_(e_invexpr2), s);
clear_tv(&rettv);
goto theend; goto theend;
} }
if (map) { if (map) {

View File

@@ -259,7 +259,7 @@ static int included_patches[] = {
528, 528,
527, 527,
//526, //526,
//525, 525,
//524, //524,
//523 NA //523 NA
//522 NA //522 NA