patch 8.2.5016: access before start of text with a put command
Problem: Access before start of text with a put command.
Solution: Check the length is more than zero.
diff --git a/src/register.c b/src/register.c
index 5ebaa05..d5a56ae 100644
--- a/src/register.c
+++ b/src/register.c
@@ -2219,9 +2219,12 @@
len = STRLEN(y_array[y_size - 1]);
col = (colnr_T)len - lendiff;
if (col > 1)
- curbuf->b_op_end.col = col - 1
- - mb_head_off(y_array[y_size - 1],
+ {
+ curbuf->b_op_end.col = col - 1;
+ if (len > 0)
+ curbuf->b_op_end.col -= mb_head_off(y_array[y_size - 1],
y_array[y_size - 1] + len - 1);
+ }
else
curbuf->b_op_end.col = 0;