To: vim_dev@googlegroups.com Subject: Patch 8.2.5024 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5024 Problem: Using freed memory with "]d". Solution: Copy the pattern before searching. Files: src/normal.c, src/testdir/test_tagjump.vim *** ../vim-8.2.5023/src/normal.c 2022-05-26 15:56:18.069351933 +0100 --- src/normal.c 2022-05-26 16:29:44.708375062 +0100 *************** *** 4464,4469 **** --- 4464,4474 ---- clearop(cap->oap); else { + // Make a copy, if the line was changed it will be freed. + ptr = vim_strnsave(ptr, len); + if (ptr == NULL) + return; + find_pattern_in_path(ptr, 0, len, TRUE, cap->count0 == 0 ? !isupper(cap->nchar) : FALSE, ((cap->nchar & 0xf) == ('d' & 0xf)) ? FIND_DEFINE : FIND_ANY, *************** *** 4472,4477 **** --- 4477,4483 ---- islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO, cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : (linenr_T)1, (linenr_T)MAXLNUM); + vim_free(ptr); curwin->w_set_curswant = TRUE; } } *** ../vim-8.2.5023/src/testdir/test_tagjump.vim 2022-05-18 16:29:04.345637132 +0100 --- src/testdir/test_tagjump.vim 2022-05-26 16:24:35.580570656 +0100 *************** *** 1399,1404 **** --- 1399,1410 ---- sil norm o0 sil! norm  bwipe! + + new somefile + call setline(1, ['first line', '', '#define something 0']) + sil norm 0o0 + sil! norm ]d + bwipe! endfunc " Test for [*, [/, ]* and ]/ *** ../vim-8.2.5023/src/version.c 2022-05-26 15:56:18.073351934 +0100 --- src/version.c 2022-05-26 16:31:32.884224729 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 5024, /**/ -- You were lucky. We lived for three months in a brown paper bag in a septic tank. We used to have to get up at six o'clock in the morning, clean the bag, eat a crust of stale bread, go to work down mill for fourteen hours a day week in-week out. When we got home, our Dad would thrash us to sleep with his belt! /// 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 ///