patch 7.4.2137
Problem: Using function() with a name will find another function when it is
redefined.
Solution: Add funcref(). Refer to lambda using a partial. Fix several
reference counting issues.
diff --git a/src/channel.c b/src/channel.c
index 3b8b5af..5ee05e3 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1124,15 +1124,18 @@
if (callback != NULL && *callback != NUL)
{
if (partial != NULL)
- *cbp = partial->pt_name;
+ *cbp = partial_name(partial);
else
+ {
*cbp = vim_strsave(callback);
+ func_ref(*cbp);
+ }
}
else
*cbp = NULL;
*pp = partial;
- if (*pp != NULL)
- ++(*pp)->pt_refcount;
+ if (partial != NULL)
+ ++partial->pt_refcount;
}
/*
@@ -1279,7 +1282,10 @@
item->cq_callback = callback;
}
else
+ {
item->cq_callback = vim_strsave(callback);
+ func_ref(item->cq_callback);
+ }
item->cq_seq_nr = id;
item->cq_prev = head->cq_prev;
head->cq_prev = item;
@@ -3923,14 +3929,24 @@
{
if (opt->jo_partial != NULL)
partial_unref(opt->jo_partial);
+ else if (opt->jo_callback != NULL)
+ func_unref(opt->jo_callback);
if (opt->jo_out_partial != NULL)
partial_unref(opt->jo_out_partial);
+ else if (opt->jo_out_cb != NULL)
+ func_unref(opt->jo_out_cb);
if (opt->jo_err_partial != NULL)
partial_unref(opt->jo_err_partial);
+ else if (opt->jo_err_cb != NULL)
+ func_unref(opt->jo_err_cb);
if (opt->jo_close_partial != NULL)
partial_unref(opt->jo_close_partial);
+ else if (opt->jo_close_cb != NULL)
+ func_unref(opt->jo_close_cb);
if (opt->jo_exit_partial != NULL)
partial_unref(opt->jo_exit_partial);
+ else if (opt->jo_exit_cb != NULL)
+ func_unref(opt->jo_exit_cb);
}
/*
@@ -4476,7 +4492,10 @@
++job->jv_exit_partial->pt_refcount;
}
else
+ {
job->jv_exit_cb = vim_strsave(opt->jo_exit_cb);
+ func_ref(job->jv_exit_cb);
+ }
}
}
}