Patch 9.0.0164
Problem: Using freed memory with put command.
Solution: Get byte offset before replacing the line.
Files: src/register.c
*** ../vim-9.0.0163/src/register.c 2022-08-07 14:55:09.543290953 +0100
--- src/register.c 2022-08-07 18:02:48.302005163 +0100
***************
*** 2099,2111 ****
ptr += yanklen;
}
STRMOVE(ptr, oldp + col);
- ml_replace(lnum, newp, FALSE);
-
- inserted_bytes(lnum, col, totlen);
// compute the byte offset for the last character
first_byte_off = mb_head_off(newp, ptr - 1);
// Place cursor on last putted char.
if (lnum == curwin->w_cursor.lnum)
{
--- 2099,2113 ----
ptr += yanklen;
}
STRMOVE(ptr, oldp + col);
// compute the byte offset for the last character
first_byte_off = mb_head_off(newp, ptr - 1);
+ // Note: this may free "newp"
+ ml_replace(lnum, newp, FALSE);
+
+ inserted_bytes(lnum, col, totlen);
+
// Place cursor on last putted char.
if (lnum == curwin->w_cursor.lnum)
{
*** ../vim-9.0.0163/src/version.c 2022-08-07 14:55:09.547290962 +0100
--- src/version.c 2022-08-07 18:08:42.645941350 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 164,
/**/
--
hundred-and-one symptoms of being an internet addict:
269. You wonder how you can make your dustbin produce Sesame Street's
Oscar's the Garbage Monster song when you empty it.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220807171102.A7D4F1C0EC3%40moolenaar.net.