To: vim_dev@googlegroups.com Subject: Patch 8.2.3949 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3949 Problem: Using freed memory with /\%V. Solution: Get the line again after getvvcol(). Files: src/regexp.c, src/testdir/test_regexp_latin.vim *** ../vim-8.2.3948/src/regexp.c 2021-12-13 14:26:40.992627753 +0000 --- src/regexp.c 2021-12-30 14:46:55.533679163 +0000 *************** *** 1310,1318 **** if (lnum < top.lnum || lnum > bot.lnum) return FALSE; if (mode == 'v') { - col = (colnr_T)(rex.input - rex.line); if ((lnum == top.lnum && col < top.col) || (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e'))) return FALSE; --- 1310,1318 ---- if (lnum < top.lnum || lnum > bot.lnum) return FALSE; + col = (colnr_T)(rex.input - rex.line); if (mode == 'v') { if ((lnum == top.lnum && col < top.col) || (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e'))) return FALSE; *************** *** 1327,1333 **** end = end2; if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL) end = MAXCOL; ! cols = win_linetabsize(wp, rex.line, (colnr_T)(rex.input - rex.line)); if (cols < start || cols > end - (*p_sel == 'e')) return FALSE; } --- 1327,1338 ---- end = end2; if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL) end = MAXCOL; ! ! // getvvcol() flushes rex.line, need to get it again ! rex.line = reg_getline(rex.lnum); ! rex.input = rex.line + col; ! ! cols = win_linetabsize(wp, rex.line, col); if (cols < start || cols > end - (*p_sel == 'e')) return FALSE; } *** ../vim-8.2.3948/src/testdir/test_regexp_latin.vim 2021-11-17 18:22:52.980044225 +0000 --- src/testdir/test_regexp_latin.vim 2021-12-30 14:43:13.617998398 +0000 *************** *** 1045,1048 **** --- 1045,1056 ---- bwipe! endfunc + func Test_using_visual_position() + " this was using freed memory + new + exe "norm 0o\\k\o0" + /\%V + bwipe! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3948/src/version.c 2021-12-30 13:59:17.038036582 +0000 --- src/version.c 2021-12-30 14:48:16.797563418 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3949, /**/ -- hundred-and-one symptoms of being an internet addict: 154. You fondle your mouse. /// 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 ///