vim-patch:9.0.1477: crash when recovering from corrupted swap file

Problem:    Crash when recovering from corrupted swap file.
Solution:   Check for a valid page count. (closes vim/vim#12275)

b67ba03d3e

Co-authored-by: Bram Moolenaar <Bram@vim.org>
(cherry picked from commit dcb6b5c62d)
This commit is contained in:
zeertzjq
2023-04-23 07:47:32 +08:00
committed by github-actions[bot]
parent c52085997b
commit e937b9a9c7
3 changed files with 35 additions and 3 deletions

View File

@@ -259,6 +259,14 @@ func Test_recover_corrupted_swap_file()
call assert_equal(['???EMPTY BLOCK'], getline(1, '$'))
bw!
" set the number of pointers in a pointer block to a large value
let b = copy(save_b)
let b[4098:4099] = 0zFFFF
call writefile(b, sn)
call assert_fails('recover Xfile1', 'E1364:')
call assert_equal('Xfile1', @%)
bw!
" set the block number in a pointer entry to a negative number
let b = copy(save_b)
if system_64bit