0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

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 #4769)
This commit is contained in:
Bram Moolenaar
2019-08-04 18:55:35 +02:00
parent c363fe1599
commit fb06d767a8
3 changed files with 26 additions and 0 deletions

View File

@@ -335,6 +335,24 @@ func Test_undofile_earlier()
call delete('Xundofile')
endfunc
" Check that reading a truncted undo file doesn't hang.
func Test_undofile_truncated()
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
" Test for undo working properly when executing commands from a register.
" Also test this in an empty buffer.
func Test_cmd_in_reg_undo()

View File

@@ -1317,6 +1317,12 @@ unserialize_uhp(bufinfo_T *bi, char_u *file_name)
int len = undo_read_byte(bi);
int what;
if (len == EOF)
{
corruption_error("truncated", file_name);
u_free_uhp(uhp);
return NULL;
}
if (len == 0)
break;
what = undo_read_byte(bi);

View File

@@ -773,6 +773,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1812,
/**/
1811,
/**/