diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-07-25 19:42:02 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-07-25 19:42:02 +0100 |
commit | 4dc513a22c017b3061287deac74fa55f70a3214c (patch) | |
tree | 54d3fe5d91474b198a259a4b77c926cb45f287d6 | |
parent | 0c740e745a5f8702fd87689615a9684664e40764 (diff) | |
download | vim-git-4dc513a22c017b3061287deac74fa55f70a3214c.tar.gz |
patch 9.0.0070: using utfc_ptr2char_len() when length is negativev9.0.0070
Problem: Using utfc_ptr2char_len() when length is negative.
Solution: Check value of length. (closes #10760)
-rw-r--r-- | src/screen.c | 21 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/screen.c b/src/screen.c index 694424745..1093b7c61 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1571,21 +1571,18 @@ screen_puts_len( // check if this is the first byte of a multibyte if (has_mbyte) { - if (enc_utf8 && len > 0) - mbyte_blen = utfc_ptr2len_len(ptr, (int)((text + len) - ptr)); - else - mbyte_blen = (*mb_ptr2len)(ptr); + mbyte_blen = enc_utf8 && len > 0 + ? utfc_ptr2len_len(ptr, (int)((text + len) - ptr)) + : (*mb_ptr2len)(ptr); if (enc_dbcs == DBCS_JPNU && c == 0x8e) mbyte_cells = 1; else if (enc_dbcs != 0) mbyte_cells = mbyte_blen; else // enc_utf8 { - if (len >= 0) - u8c = utfc_ptr2char_len(ptr, u8cc, - (int)((text + len) - ptr)); - else - u8c = utfc_ptr2char(ptr, u8cc); + u8c = len >= 0 + ? utfc_ptr2char_len(ptr, u8cc, (int)((text + len) - ptr)) + : utfc_ptr2char(ptr, u8cc); mbyte_cells = utf_char2cells(u8c); #ifdef FEAT_ARABIC if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c)) @@ -1599,8 +1596,10 @@ screen_puts_len( } else { - nc = utfc_ptr2char_len(ptr + mbyte_blen, pcc, - (int)((text + len) - ptr - mbyte_blen)); + nc = len >= 0 + ? utfc_ptr2char_len(ptr + mbyte_blen, pcc, + (int)((text + len) - ptr - mbyte_blen)) + : utfc_ptr2char(ptr + mbyte_blen, pcc); nc1 = pcc[0]; } pc = prev_c; diff --git a/src/version.c b/src/version.c index a07ccb748..83d135db2 100644 --- a/src/version.c +++ b/src/version.c @@ -736,6 +736,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 70, +/**/ 69, /**/ 68, |