To: vim_dev@googlegroups.com Subject: Patch 8.1.2119 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2119 Problem: memory access error for empty string when 'encoding' is a single byte encoding. Solution: Check for empty string when getting the length. (Dominique Pelle, closes #5021, closes #5007) Files: src/macros.h *** ../vim-8.1.2118/src/macros.h 2019-06-16 15:50:42.012557682 +0200 --- src/macros.h 2019-10-06 12:56:09.851478672 +0200 *************** *** 230,240 **** * PTR2CHAR(): get character from pointer. */ /* Get the length of the character p points to, including composing chars */ ! #define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1) /* Advance multi-byte pointer, skip over composing chars. */ ! #define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1 /* Advance multi-byte pointer, do not skip over composing chars. */ ! #define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1 /* Backup multi-byte pointer. Only use with "p" > "s" ! */ #define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1 /* get length of multi-byte char, not including composing chars */ --- 230,240 ---- * PTR2CHAR(): get character from pointer. */ /* Get the length of the character p points to, including composing chars */ ! #define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : (*p == NUL ? 0 : 1)) /* Advance multi-byte pointer, skip over composing chars. */ ! #define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : (*p == NUL ? 0 : 1) /* Advance multi-byte pointer, do not skip over composing chars. */ ! #define MB_CPTR_ADV(p) p += enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : (*p == NUL ? 0 : 1) /* Backup multi-byte pointer. Only use with "p" > "s" ! */ #define MB_PTR_BACK(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1 /* get length of multi-byte char, not including composing chars */ *** ../vim-8.1.2118/src/version.c 2019-10-06 12:02:10.756520967 +0200 --- src/version.c 2019-10-06 12:59:38.213610636 +0200 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 2119, /**/ -- My girlfriend told me I should be more affectionate. So I got TWO girlfriends. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///