Skip to content

Commit 0588d4f

Browse files
committed
patch 7.4.2139
Problem: :delfunction causes illegal memory access. Solution: Correct logic when deciding to free a function.
1 parent 2d3d60a commit 0588d4f

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/testdir/test_lambda.vim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ func Test_closure_refcount()
267267
call assert_equal(2, g:Count())
268268
call assert_equal(3, g:Count2())
269269

270-
" This causes memory access errors.
271-
" delfunc LambdaFoo
272-
" delfunc LambdaBar
270+
delfunc LambdaFoo
271+
delfunc LambdaBar
273272
endfunc

src/userfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2711,7 +2711,7 @@ ex_delfunction(exarg_T *eap)
27112711
* Numbered functions and lambdas snould be kept if the refcount is
27122712
* one or more. */
27132713
if (fp->uf_refcount > (isdigit(fp->uf_name[0])
2714-
|| fp->uf_name[0] == '<') ? 0 : 1)
2714+
|| fp->uf_name[0] == '<' ? 0 : 1))
27152715
{
27162716
/* Function is still referenced somewhere. Don't free it but
27172717
* do remove it from the hashtable. */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static char *(features[]) =
763763

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2139,
766768
/**/
767769
2138,
768770
/**/

0 commit comments

Comments
 (0)