mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.1812: reading a truncted undo file hangs Vim
Problem: Reading a truncted undo file hangs Vim.
Solution: Check for reading EOF. (closes vim/vim#4769)
fb06d767a8
This commit is contained in:
parent
da5bd45e5a
commit
8bd38863e6
@ -364,6 +364,25 @@ func Test_wundo_errors()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Check that reading a truncted undo file doesn't hang.
|
||||||
|
func Test_undofile_truncated()
|
||||||
|
throw 'skipped: TODO: '
|
||||||
|
new
|
||||||
|
call setline(1, 'hello')
|
||||||
|
set ul=100
|
||||||
|
wundo Xundofile
|
||||||
|
let contents = readfile('Xundofile', 'B')
|
||||||
|
|
||||||
|
" try several sizes
|
||||||
|
for size in range(20, 500, 33)
|
||||||
|
call writefile(contents[0:size], 'Xundofile')
|
||||||
|
call assert_fails('rundo Xundofile', 'E825:')
|
||||||
|
endfor
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
" call delete('Xundofile')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_rundo_errors()
|
func Test_rundo_errors()
|
||||||
call assert_fails('rundo XfileDoesNotExist', 'E822:')
|
call assert_fails('rundo XfileDoesNotExist', 'E822:')
|
||||||
|
|
||||||
|
@ -878,7 +878,12 @@ static u_header_T *unserialize_uhp(bufinfo_T *bi,
|
|||||||
for (;; ) {
|
for (;; ) {
|
||||||
int len = undo_read_byte(bi);
|
int len = undo_read_byte(bi);
|
||||||
|
|
||||||
if (len == 0 || len == EOF) {
|
if (len == EOF) {
|
||||||
|
corruption_error("truncated", file_name);
|
||||||
|
u_free_uhp(uhp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (len == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int what = undo_read_byte(bi);
|
int what = undo_read_byte(bi);
|
||||||
|
Loading…
Reference in New Issue
Block a user