mirror of
https://github.com/vim/vim.git
synced 2025-10-16 07:24:23 -04:00
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: #18437 Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@@ -2226,6 +2226,7 @@ calculate_topfill_and_topline(
|
|||||||
diff_T *thistopdiff = NULL;
|
diff_T *thistopdiff = NULL;
|
||||||
diff_T *next_adjacent_blocks = NULL;
|
diff_T *next_adjacent_blocks = NULL;
|
||||||
int virtual_lines_passed = 0;
|
int virtual_lines_passed = 0;
|
||||||
|
int curlinenum_to = 1;
|
||||||
|
|
||||||
find_top_diff_block(&thistopdiff, &next_adjacent_blocks, fromidx, from_topline);
|
find_top_diff_block(&thistopdiff, &next_adjacent_blocks, fromidx, from_topline);
|
||||||
|
|
||||||
@@ -2253,7 +2254,8 @@ calculate_topfill_and_topline(
|
|||||||
|
|
||||||
// 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];
|
if (thistopdiff != NULL)
|
||||||
|
curlinenum_to = thistopdiff->df_lnum[toidx];
|
||||||
|
|
||||||
int virt_lines_left = virtual_lines_passed;
|
int virt_lines_left = virtual_lines_passed;
|
||||||
curdif = thistopdiff;
|
curdif = thistopdiff;
|
||||||
|
@@ -143,6 +143,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
|
||||||
@@ -152,6 +174,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, '$'))
|
||||||
|
@@ -729,6 +729,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1818,
|
||||||
/**/
|
/**/
|
||||||
1817,
|
1817,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user