To: vim_dev@googlegroups.com Subject: Patch 8.2.4762 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4762 Problem: Using freed memory when using synstack() and synID() in WinEnter. Solution: Check using the syntax window. (closes #10204) Files: src/syntax.c, src/testdir/test_syntax.vim *** ../vim-8.2.4761/src/syntax.c 2022-04-07 13:26:30.153944670 +0100 --- src/syntax.c 2022-04-16 16:47:37.758683489 +0100 *************** *** 6486,6493 **** int keep_state) // keep state of char at "col" { // When the position is not after the current position and in the same ! // line of the same buffer, need to restart parsing. ! if (wp->w_buffer != syn_buf || lnum != current_lnum || col < current_col) syntax_start(wp, lnum); --- 6486,6494 ---- int keep_state) // keep state of char at "col" { // When the position is not after the current position and in the same ! // line of the same window with the same buffer, need to restart parsing. ! if (wp != syn_win ! || wp->w_buffer != syn_buf || lnum != current_lnum || col < current_col) syntax_start(wp, lnum); *** ../vim-8.2.4761/src/testdir/test_syntax.vim 2021-12-17 17:32:26.101900897 +0000 --- src/testdir/test_syntax.vim 2022-04-16 16:42:41.246708401 +0100 *************** *** 956,960 **** --- 956,973 ---- bw! endfunc + " This was using freed memory + func Test_WinEnter_synstack_synID() + autocmd WinEnter * call synstack(line("."), col(".")) + autocmd WinEnter * call synID(line('.'), col('.') - 1, 1) + call setline(1, 'aaaaa') + normal! $ + new + close + + au! WinEnter + bw! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4761/src/version.c 2022-04-16 15:18:19.428831638 +0100 --- src/version.c 2022-04-16 16:48:01.174679196 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4762, /**/ -- You have heard the saying that if you put a thousand monkeys in a room with a thousand typewriters and waited long enough, eventually you would have a room full of dead monkeys. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///