Skip to content

Commit

Permalink
patch 9.0.0750: crash when popup closed in callback
Browse files Browse the repository at this point in the history
Problem:    Crash when popup closed in callback. (Maxim Kim)
Solution:   In syntax_end_parsing() check that syn_block is valid.
  • Loading branch information
brammool committed Oct 14, 2022
1 parent 975a665 commit 0abd6cf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/drawscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2486,7 +2486,7 @@ win_update(win_T *wp)
// 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);
#endif

// Display one line.
Expand Down Expand Up @@ -2601,7 +2601,7 @@ win_update(win_T *wp)
#ifdef FEAT_SYN_HL
// 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);
#endif

// If we didn't hit the end of the file, and we didn't finish the last
Expand Down
2 changes: 1 addition & 1 deletion src/proto/syntax.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
void syntax_start(win_T *wp, linenr_T lnum);
void syn_stack_free_all(synblock_T *block);
void syn_stack_apply_changes(buf_T *buf);
void syntax_end_parsing(linenr_T lnum);
void syntax_end_parsing(win_T *wp, linenr_T lnum);
int syntax_check_changed(linenr_T lnum);
int get_syntax_attr(colnr_T col, int *can_spell, int keep_state);
void syntax_clear(synblock_T *block);
Expand Down
4 changes: 3 additions & 1 deletion src/syntax.c
Original file line number Diff line number Diff line change
Expand Up @@ -1542,10 +1542,12 @@ syn_stack_equal(synstate_T *sp)
* lnum -> line below window
*/
void
syntax_end_parsing(linenr_T lnum)
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;
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
750,
/**/
749,
/**/
Expand Down

0 comments on commit 0abd6cf

Please sign in to comment.