]> granicus.if.org Git - vim/commitdiff
patch 8.2.2934: ASAN error when using text from the clipboard v8.2.2934
authorBram Moolenaar <Bram@vim.org>
Fri, 4 Jun 2021 16:33:49 +0000 (18:33 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 4 Jun 2021 16:33:49 +0000 (18:33 +0200)
Problem:    ASAN error when using text from the clipboard.
Solution:   Get width of each character.

src/register.c
src/version.c

index 8680c6bf325ec1f4d4d4c8efb3f9f950404daa82..8c951b7eabab9b8c6c903ec34a84faba6f1869cb 100644 (file)
@@ -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;
index ab4ffeb39babf0cea37f367012251d1153746f92..eab59f42efbf14fc7b2f42d25acf6eb76da7e57c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2934,
 /**/
     2933,
 /**/