mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.0220: invalid memory access with for loop over NULL string
Problem: Invalid memory access with for loop over NULL string.
Solution: Make sure mb_ptr2len() consistently returns zero for NUL.
f6d39c31d2
This commit is contained in:
parent
542fa8a9cc
commit
65bcec9e9b
@ -890,9 +890,9 @@ int utf_ptr2len_len(const char_u *p, int size)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the number of bytes occupied by a UTF-8 character in a string
|
/// Return the number of bytes occupied by a UTF-8 character in a string.
|
||||||
///
|
|
||||||
/// This includes following composing characters.
|
/// This includes following composing characters.
|
||||||
|
/// Returns zero for NUL.
|
||||||
int utfc_ptr2len(const char *const p_in)
|
int utfc_ptr2len(const char *const p_in)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,18 @@ func Test_for_invalid()
|
|||||||
redraw
|
redraw
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_for_over_null_string()
|
||||||
|
let save_enc = &enc
|
||||||
|
" set enc=iso8859
|
||||||
|
let cnt = 0
|
||||||
|
for c in v:_null_string
|
||||||
|
let cnt += 1
|
||||||
|
endfor
|
||||||
|
call assert_equal(0, cnt)
|
||||||
|
|
||||||
|
let &enc = save_enc
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_readfile_binary()
|
func Test_readfile_binary()
|
||||||
new
|
new
|
||||||
call setline(1, ['one', 'two', 'three'])
|
call setline(1, ['one', 'two', 'three'])
|
||||||
|
Loading…
Reference in New Issue
Block a user