vim-patch:9.0.1477: crash when recovering from corrupted swap file (#23273)

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>
This commit is contained in:
zeertzjq
2023-04-23 08:24:10 +08:00
committed by GitHub
parent 431b152726
commit 77ff25b1d9
3 changed files with 35 additions and 3 deletions

View File

@@ -300,7 +300,12 @@ bhdr_T *mf_get(memfile_T *mfp, blocknr_T nr, unsigned page_count)
// could check here if the block is in the free list
hp = mf_alloc_bhdr(mfp, page_count);
if (page_count > 0) {
hp = mf_alloc_bhdr(mfp, page_count);
}
if (hp == NULL) {
return NULL;
}
hp->bh_bnum = nr;
hp->bh_flags = 0;