diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-02-15 20:39:46 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-02-15 20:39:46 +0100 |
commit | 3bece9fee9c02934d3e295b29d253e13d4ef26a7 (patch) | |
tree | 716659cb27215968e8e7790ac674cc456068ad2f /src/eval.c | |
parent | 71b0f7b5c083d32fd37fa825f5d829b6a6c1a09a (diff) |
patch 7.4.1322v7.4.1322
Problem: Crash when unletting the variable that holds the channel in a
callback function. (Christian Robinson)
Solution: Increase the reference count while invoking the callback.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c index a36f3dd51d..53d41d1d98 100644 --- a/src/eval.c +++ b/src/eval.c @@ -7730,12 +7730,21 @@ failret: return OK; } -#ifdef FEAT_CHANNEL - static void +#if defined(FEAT_CHANNEL) || defined(PROTO) +/* + * Decrement the reference count on "channel" and free it when it goes down to + * zero. + * Returns TRUE when the channel was freed. + */ + int channel_unref(channel_T *channel) { if (channel != NULL && --channel->ch_refcount <= 0) + { channel_free(channel); + return TRUE; + } + return FALSE; } #endif |