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:
watiko 2016-02-16 23:05:47 +09:00 committed by Justin M. Keyes
parent bfe9ebcbe1
commit 9403ce82bc
3 changed files with 21 additions and 4 deletions

View File

@ -250,6 +250,14 @@ static unsigned int handle_mouse_event(char **ptr, uint8_t *buf,
int col, row, advance;
if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance) != EOF && advance) {
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_col = col;
}

View File

@ -354,7 +354,7 @@ static int included_patches[] = {
939,
// 938 NA
937,
// 936,
936,
// 935 NA
// 934 NA
933,

View File

@ -4575,10 +4575,19 @@ void win_drag_vsep_line(win_T *dragwin, int offset)
}
assert(fr);
if (room < offset) /* Not enough room */
offset = room; /* Move as far as we can */
if (offset <= 0) /* No room at all, quit. */
// Not enough room
if (room < offset) {
offset = room; // Move as far as we can
}
// No room at all, quit.
if (offset <= 0) {
return;
}
if (fr == NULL) {
return; // Safety check, should not happen.
}
/* grow frame fr by offset lines */
frame_new_width(fr, fr->fr_width + offset, left, FALSE);