diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-04 18:33:49 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-04 18:33:49 +0200 |
commit | 24951a67c24e75ec4ff7506f8e2e789ccd786e89 (patch) | |
tree | 18d1f1074f3bb67d72577d587103c0f07d0da3e3 | |
parent | 6e0b553fa12fc5ad5d8ee3d8457e7cb16f38b56f (diff) | |
download | vim-git-24951a67c24e75ec4ff7506f8e2e789ccd786e89.tar.gz |
patch 8.2.2934: ASAN error when using text from the clipboardv8.2.2934
Problem: ASAN error when using text from the clipboard.
Solution: Get width of each character.
-rw-r--r-- | src/register.c | 7 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/register.c b/src/register.c index 8680c6bf3..8c951b7ea 100644 --- a/src/register.c +++ b/src/register.c @@ -2908,11 +2908,12 @@ str_to_reg( { charlen = 0; for (i = start; i < len; ++i) // find the end of the line + { if (str[i] == '\n') break; + charlen += mb_ptr2cells_len(str + i, len - i); + } i -= start; // i is now length of line - if (start < len) - charlen = mb_charlen_len(str + start, i); if (charlen > maxlen) maxlen = charlen; if (append) @@ -2929,7 +2930,7 @@ str_to_reg( mch_memmove(s, y_ptr->y_array[lnum], (size_t)extra); if (append) vim_free(y_ptr->y_array[lnum]); - if (i) + if (i > 0) mch_memmove(s + extra, str + start, (size_t)i); extra += i; s[extra] = NUL; diff --git a/src/version.c b/src/version.c index ab4ffeb39..eab59f42e 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2934, +/**/ 2933, /**/ 2932, |