From 7a011cb58d7bad2730f81bff323504357d787e9b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 15 Oct 2022 07:31:41 +0800 Subject: [PATCH] vim-patch:9.0.0750: crash when popup closed in callback (#20660) vim-patch:9.0.0750: crash when popup closed in callback Problem: Crash when popup closed in callback. (Maxim Kim) Solution: In syntax_end_parsing() check that syn_block is valid. https://github.com/vim/vim/commit/0abd6cf62d65180dc2c40d67cd95f13b0691f7ea (cherry picked from commit 2a2ae32cebe40c709389ca5d0d5c273d454b650c) --- src/nvim/drawscreen.c | 4 ++-- src/nvim/syntax.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index fdf70a081c..6d903d0025 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -1828,7 +1828,7 @@ win_update_start: // Let the syntax stuff know we skipped a few lines. if (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum && syntax_present(wp)) { - syntax_end_parsing(syntax_last_parsed + 1); + syntax_end_parsing(wp, syntax_last_parsed + 1); } // Display one line @@ -1902,7 +1902,7 @@ win_update_start: // Let the syntax stuff know we stop parsing here. if (syntax_last_parsed != 0 && syntax_present(wp)) { - syntax_end_parsing(syntax_last_parsed + 1); + syntax_end_parsing(wp, syntax_last_parsed + 1); } // If we didn't hit the end of the file, and we didn't finish the last diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 575d475b87..ea78397d8c 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -1327,10 +1327,13 @@ static bool syn_stack_equal(synstate_T *sp) // displayed line // displayed line // lnum -> line below window -void syntax_end_parsing(linenr_T lnum) +void syntax_end_parsing(win_T *wp, linenr_T lnum) { synstate_T *sp; + if (syn_block != wp->w_s) { + return; // not the right window + } sp = syn_stack_find_entry(lnum); if (sp != NULL && sp->sst_lnum < lnum) { sp = sp->sst_next;