summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2024-05-08 22:17:19 +0200
committerChristian Brabandt <cb@256bit.org>2024-05-08 22:17:19 +0200
commitd5c8c0920e1eee9ff7a9fa5168d8e85c01670630 (patch)
treeaf52487bbf563bb1fcdfec770e07ff3dea60fce6
parentcb3691811be93b2c49179649c684d6ce2141a46f (diff)
patch 9.1.0399: block_editing errors out when using delv9.1.0399
Problem: block_editing errors out when using del (@Jamarley) Solution: Change ins_len from size_t to int and properly check that it doesn't become negative There is a check in os.c that verifies that `ins_len` does not become negative: ``` if (pre_textlen >= 0 && (ins_len = len - pre_textlen - offset) > 0) ``` However this only works, if ins_len can actually become negative and unfortunately, ins_len has been declared as `size_t` so instead of becoming negative it will wrap around and be very large. So let's define it as integer, after which the condition above properly catches this condition. fixes: #14734 closes: #14735 Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--src/ops.c2
-rw-r--r--src/testdir/test_visual.vim8
-rw-r--r--src/version.c2
3 files changed, 11 insertions, 1 deletions
diff --git a/src/ops.c b/src/ops.c
index e3e782756e..cdc30806ce 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -1608,7 +1608,7 @@ op_insert(oparg_T *oap, long count1)
if (oap->block_mode)
{
- size_t ins_len;
+ int ins_len;
char_u *firstline, *ins_text;
struct block_def bd2;
int did_indent = FALSE;
diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
index 9b8eed40e7..b3049281b9 100644
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -2031,4 +2031,12 @@ func Test_getregion_maxcol()
bwipe!
endfunc
+func Test_visual_block_cursor_delete()
+ new
+ call setline(1, 'ab')
+ exe ":norm! $\<c-v>hI\<Del>\<ESC>"
+ call assert_equal(['b'], getline(1, 1))
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index ba03c1a506..06f0c62760 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 399,
+/**/
398,
/**/
397,