mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 06:18:16 +00:00
vim-patch:7.4.936 #4271
Problem: Crash when dragging with the mouse.
Solution: Add safety check for NULL pointer. Check mouse position for valid
value. (Hirohito Higashi)
294a7e55b0
---
see: "Crash while mouse-selecting in two-buffer mode"
https://github.com/vim/vim/issues/486
Fix #3704
This commit is contained in:
@@ -250,6 +250,14 @@ static unsigned int handle_mouse_event(char **ptr, uint8_t *buf,
|
|||||||
int col, row, advance;
|
int col, row, advance;
|
||||||
if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance) != EOF && advance) {
|
if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance) != EOF && advance) {
|
||||||
if (col >= 0 && row >= 0) {
|
if (col >= 0 && row >= 0) {
|
||||||
|
// Make sure the mouse position is valid. Some terminals may
|
||||||
|
// return weird values.
|
||||||
|
if (col >= Columns) {
|
||||||
|
col = (int)Columns - 1;
|
||||||
|
}
|
||||||
|
if (row >= Rows) {
|
||||||
|
row = (int)Rows - 1;
|
||||||
|
}
|
||||||
mouse_row = row;
|
mouse_row = row;
|
||||||
mouse_col = col;
|
mouse_col = col;
|
||||||
}
|
}
|
||||||
|
@@ -354,7 +354,7 @@ static int included_patches[] = {
|
|||||||
939,
|
939,
|
||||||
// 938 NA
|
// 938 NA
|
||||||
937,
|
937,
|
||||||
// 936,
|
936,
|
||||||
// 935 NA
|
// 935 NA
|
||||||
// 934 NA
|
// 934 NA
|
||||||
933,
|
933,
|
||||||
|
@@ -4575,10 +4575,19 @@ void win_drag_vsep_line(win_T *dragwin, int offset)
|
|||||||
}
|
}
|
||||||
assert(fr);
|
assert(fr);
|
||||||
|
|
||||||
if (room < offset) /* Not enough room */
|
// Not enough room
|
||||||
offset = room; /* Move as far as we can */
|
if (room < offset) {
|
||||||
if (offset <= 0) /* No room at all, quit. */
|
offset = room; // Move as far as we can
|
||||||
|
}
|
||||||
|
|
||||||
|
// No room at all, quit.
|
||||||
|
if (offset <= 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fr == NULL) {
|
||||||
|
return; // Safety check, should not happen.
|
||||||
|
}
|
||||||
|
|
||||||
/* grow frame fr by offset lines */
|
/* grow frame fr by offset lines */
|
||||||
frame_new_width(fr, fr->fr_width + offset, left, FALSE);
|
frame_new_width(fr, fr->fr_width + offset, left, FALSE);
|
||||||
|
Reference in New Issue
Block a user