vim-patch:8.1.0437: may access freed memory when syntax HL times out

Problem:    May access freed memory when syntax HL times out. (Philipp Gesang)
Solution:   Clear b_sst_first when clearing b_sst_array.
95892c27b2
This commit is contained in:
Jan Edmund Lazo
2019-06-24 23:31:33 -04:00
parent 615fc68263
commit dfd050867b

View File

@@ -997,6 +997,7 @@ static void syn_stack_free_block(synblock_T *block)
clear_syn_state(p); clear_syn_state(p);
} }
XFREE_CLEAR(block->b_sst_array); XFREE_CLEAR(block->b_sst_array);
block->b_sst_first = NULL;
block->b_sst_len = 0; block->b_sst_len = 0;
} }
} }
@@ -1108,9 +1109,6 @@ static void syn_stack_apply_changes_block(synblock_T *block, buf_T *buf)
synstate_T *p, *prev, *np; synstate_T *p, *prev, *np;
linenr_T n; linenr_T n;
if (block->b_sst_array == NULL) /* nothing to do */
return;
prev = NULL; prev = NULL;
for (p = block->b_sst_first; p != NULL; ) { for (p = block->b_sst_first; p != NULL; ) {
if (p->sst_lnum + block->b_syn_sync_linebreaks > buf->b_mod_top) { if (p->sst_lnum + block->b_syn_sync_linebreaks > buf->b_mod_top) {
@@ -1158,8 +1156,9 @@ static int syn_stack_cleanup(void)
int dist; int dist;
int retval = FALSE; int retval = FALSE;
if (syn_block->b_sst_array == NULL || syn_block->b_sst_first == NULL) if (syn_block->b_sst_first == NULL) {
return retval; return retval;
}
/* Compute normal distance between non-displayed entries. */ /* Compute normal distance between non-displayed entries. */
if (syn_block->b_sst_len <= Rows) if (syn_block->b_sst_len <= Rows)