Mercurial > vim
changeset 24792:91c42289cbe1 v8.2.2934
patch 8.2.2934: ASAN error when using text from the clipboard
Commit: https://github.com/vim/vim/commit/24951a67c24e75ec4ff7506f8e2e789ccd786e89
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jun 4 18:33:49 2021 +0200
patch 8.2.2934: ASAN error when using text from the clipboard
Problem: ASAN error when using text from the clipboard.
Solution: Get width of each character.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 04 Jun 2021 18:45:03 +0200 |
parents | 362a9333f234 |
children | 83d41b2de004 |
files | src/register.c src/version.c |
diffstat | 2 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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;