diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-08-12 14:11:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-12 14:11:47 +0200 |
commit | 1211fa09cfd30d6fcd15a897769586d39595a3e8 (patch) | |
tree | a6a794c2027a80ebda169559e4e6583621a90819 /src/nvim/strings.c | |
parent | ae24c9b27016a841121b1a01664b748b0a5cbeb7 (diff) | |
parent | 8ad46a25cb8f774db378f29b0e4c43bce524b76e (diff) | |
download | rneovim-1211fa09cfd30d6fcd15a897769586d39595a3e8.tar.gz rneovim-1211fa09cfd30d6fcd15a897769586d39595a3e8.tar.bz2 rneovim-1211fa09cfd30d6fcd15a897769586d39595a3e8.zip |
Merge #8833 from janlazo/vim-8.0.1004
Diffstat (limited to 'src/nvim/strings.c')
-rw-r--r-- | src/nvim/strings.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 3b075f8b70..f24de72743 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -344,14 +344,17 @@ char *strcase_save(const char *const orig, bool upper) char *p = res; while (*p != NUL) { - int l; - int c = utf_ptr2char((const char_u *)p); + int l = utf_ptr2len((const char_u *)p); + if (c == 0) { + // overlong sequence, use only the first byte + c = *p; + l = 1; + } int uc = upper ? mb_toupper(c) : mb_tolower(c); // Reallocate string when byte count changes. This is rare, // thus it's OK to do another malloc()/free(). - l = utf_ptr2len((const char_u *)p); int newl = utf_char2len(uc); if (newl != l) { // TODO(philix): use xrealloc() in strup_save() |