On Di, 24 Jan 2017, Christian Brabandt wrote:
> I'll work more on it later, if I have some more time and will add a
> test.
Here is a patch with a test. However the test does not trigger the
segfault. But I figure, it should still work and probably asan would
caught it.
Best
Christian
--
Je älter, desto mehr entschuldigt, desto weniger achtet man d(ie)
Menschen.
-- Jean Paul
--
--
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].
For more options, visit https://groups.google.com/d/optout.
From 9492b96905de7a649f5ce6b27237fb2e18cab892 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <[email protected]>
Date: Tue, 24 Jan 2017 17:57:19 +0100
Subject: [PATCH] Don't overwrite ptr in nv_put
Fixes a crash, when pasting over too short lines
---
src/ops.c | 5 +++++
src/testdir/test_put.vim | 13 +++++++++++++
2 files changed, 18 insertions(+)
diff --git a/src/ops.c b/src/ops.c
index 1abb8daa1..c815308a8 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -3784,6 +3784,11 @@ do_put(
if (totlen > 0)
{
oldp = ml_get(lnum);
+ if (VIsual_active && col > (int)STRLEN(oldp))
+ {
+ lnum++;
+ continue;
+ }
newp = alloc_check((unsigned)(STRLEN(oldp) + totlen + 1));
if (newp == NULL)
goto end; /* alloc() gave an error message */
diff --git a/src/testdir/test_put.vim b/src/testdir/test_put.vim
index 0154de1ec..2008cfd4b 100644
--- a/src/testdir/test_put.vim
+++ b/src/testdir/test_put.vim
@@ -21,3 +21,16 @@ func Test_put_char_block()
call assert_equal(['Xfile_put 1', 'Xfile_put 2'], getline(1,2))
bw!
endfunc
+
+func Test_put_char_block2()
+ new
+ let a=[ getreg('a'), getregtype('a') ]
+ call setreg('a', ' one ', 'v')
+ call setline(1, ['Line 1', '', 'Line 3', ''])
+ " visually select the first 3 lines and put register a over it
+ exe "norm! ggl\<c-v>2j2l\"ap"
+ call assert_equal(['L one 1', '', 'L one 3', ''], getline(1,4))
+ " clean up
+ bw!
+ call setreg('a', a[0], a[1])
+endfunc
--
2.11.0