mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 08:28:34 +00:00
vim-patch:9.1.1818: possible crash when calculating topline in diff.c
Problem: possible crash when calculating topline in diff.c
(youngmith)
Solution: Check for pointer being Null before accessing it
fixes: vim/vim#18437
d32b3bb7eb
The POC is likely not applicable to Nvim due to #32160.
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@@ -2052,7 +2052,7 @@ static void calculate_topfill_and_topline(const int fromidx, const int toidx, co
|
|||||||
|
|
||||||
// move the same amount of virtual lines in the target buffer to find the
|
// move the same amount of virtual lines in the target buffer to find the
|
||||||
// cursor's line number
|
// cursor's line number
|
||||||
int curlinenum_to = thistopdiff->df_lnum[toidx];
|
int curlinenum_to = thistopdiff != NULL ? thistopdiff->df_lnum[toidx] : 1;
|
||||||
|
|
||||||
int virt_lines_left = virtual_lines_passed;
|
int virt_lines_left = virtual_lines_passed;
|
||||||
curdif = thistopdiff;
|
curdif = thistopdiff;
|
||||||
|
@@ -144,6 +144,28 @@ func Test_crash1_2()
|
|||||||
call s:RunCommandAndWait(buf, args ..
|
call s:RunCommandAndWait(buf, args ..
|
||||||
\ ' ; echo "crash 5: [OK]" >> '.. result)
|
\ ' ; echo "crash 5: [OK]" >> '.. result)
|
||||||
|
|
||||||
|
let file = 'Xdiff'
|
||||||
|
let lines =<< trim END
|
||||||
|
diffs a
|
||||||
|
edit Xdiff
|
||||||
|
file b
|
||||||
|
exe "norm! \<C-w>\<C-w>"
|
||||||
|
exe "norm! \<C-w>\<C-w>"
|
||||||
|
exe "norm! \<C-w>\<C-w>"
|
||||||
|
exe "norm! \<C-w>\<C-w>"
|
||||||
|
exe "norm! \<C-w>\<C-w>"
|
||||||
|
exe "norm! \<C-w>\L"
|
||||||
|
exe "norm! \<C-j>oy\<C-j>"
|
||||||
|
edit Xdiff
|
||||||
|
sil!so
|
||||||
|
END
|
||||||
|
call writefile(lines, file, 'D')
|
||||||
|
let cmn_args = "%s -u NONE -i NONE -X -m -n -e -s -u %s -c ':qa!'"
|
||||||
|
let args = printf(cmn_args, vim, file)
|
||||||
|
call s:RunCommandAndWait(buf, args ..
|
||||||
|
\ ' && echo "crash 6: [OK]" >> '.. result)
|
||||||
|
|
||||||
|
|
||||||
" clean up
|
" clean up
|
||||||
exe buf .. "bw!"
|
exe buf .. "bw!"
|
||||||
exe "sp " .. result
|
exe "sp " .. result
|
||||||
@@ -153,6 +175,7 @@ func Test_crash1_2()
|
|||||||
\ 'crash 3: [OK]',
|
\ 'crash 3: [OK]',
|
||||||
\ 'crash 4: [OK]',
|
\ 'crash 4: [OK]',
|
||||||
\ 'crash 5: [OK]',
|
\ 'crash 5: [OK]',
|
||||||
|
\ 'crash 6: [OK]',
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
call assert_equal(expected, getline(1, '$'))
|
call assert_equal(expected, getline(1, '$'))
|
||||||
|
Reference in New Issue
Block a user