diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-04-23 08:24:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-23 08:24:10 +0800 |
commit | 77ff25b1d9ab5869d852779cae8fc6a1245f3ea7 (patch) | |
tree | 0eaf8af285049ca4972d127724bb26a465876c61 /src/nvim/memfile.c | |
parent | 431b152726013ec6a5cece0285e7c103673bc511 (diff) | |
download | rneovim-77ff25b1d9ab5869d852779cae8fc6a1245f3ea7.tar.gz rneovim-77ff25b1d9ab5869d852779cae8fc6a1245f3ea7.tar.bz2 rneovim-77ff25b1d9ab5869d852779cae8fc6a1245f3ea7.zip |
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)
https://github.com/vim/vim/commit/b67ba03d3ef2e6c5f207d508e85fc6906f938028
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/memfile.c')
-rw-r--r-- | src/nvim/memfile.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 51fa17384c..3eac44b40b 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -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; |