From a9c3a30891edd7347d94298c48ea68bb5c165fd7 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 26 Mar 2020 16:03:45 +0100 Subject: [PATCH] patch 8.2.0452: channel_parse_messages() fails when called recursively Problem: channel_parse_messages() fails when called recursively. Solution: Return for a recursive call. (closes #5835) --- src/channel.c | 13 +++++++++++-- src/version.c | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/channel.c b/src/channel.c index a57ed9ccf..15ee0b775 100644 --- a/src/channel.c +++ b/src/channel.c @@ -4428,14 +4428,22 @@ channel_parse_messages(void) int ret = FALSE; int r; ch_part_T part = PART_SOCK; + static int recursive = FALSE; #ifdef ELAPSED_FUNC elapsed_T start_tv; - - ELAPSED_INIT(start_tv); #endif + // The code below may invoke callbacks, which might call us back. + // That doesn't work well, just return without doing anything. + if (recursive) + return FALSE; + recursive = TRUE; ++safe_to_invoke_callback; +#ifdef ELAPSED_FUNC + ELAPSED_INIT(start_tv); +#endif + // Only do this message when another message was given, otherwise we get // lots of them. if ((did_repeated_msg & REPEATED_MSG_LOOKING) == 0) @@ -4513,6 +4521,7 @@ channel_parse_messages(void) } --safe_to_invoke_callback; + recursive = FALSE; return ret; } diff --git a/src/version.c b/src/version.c index 12e287dce..94fcb6096 100644 --- a/src/version.c +++ b/src/version.c @@ -738,6 +738,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 452, /**/ 451, /**/ -- 2.50.1