diff src/eval.c @ 8257:c4ffdda8cdfd v7.4.1421

commit https://github.com/vim/vim/commit/c8dcbb12c5d7f3eb0c334daebb4475bb015b91e7 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 25 23:10:17 2016 +0100 patch 7.4.1421 Problem: May free a channel when a callback may need to be invoked. Solution: Keep the channel when refcount is zero.
author Christian Brabandt <cb@256bit.org>
date Thu, 25 Feb 2016 23:15:05 +0100
parents 60586ce747c4
children 99a70c3b902f
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -7745,8 +7745,8 @@ failret:
 
 #if defined(FEAT_CHANNEL) || defined(PROTO)
 /*
- * Decrement the reference count on "channel" and free it when it goes down to
- * zero.
+ * Decrement the reference count on "channel" and maybe free it when it goes
+ * down to zero.  Don't free it if there is a pending action.
  * Returns TRUE when the channel was freed.
  */
     int
@@ -7754,7 +7754,7 @@ channel_unref(channel_T *channel)
 {
     if (channel != NULL && --channel->ch_refcount <= 0)
     {
-	channel_free(channel);
+	channel_may_free(channel);
 	return TRUE;
     }
     return FALSE;