Mercurial > vim
comparison src/misc2.c @ 10110:cfb38b57d407 v7.4.2326
commit https://github.com/vim/vim/commit/d5824ce1b5491df7d2eb0b66189d366fa67b4585
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 4 20:35:01 2016 +0200
patch 7.4.2326
Problem: Illegal memory access when Visual selection starts in invalid
position. (Dominique Pelle)
Solution: Correct position when needed.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 04 Sep 2016 20:45:05 +0200 |
parents | 4aead6a9b7a9 |
children | c036c0f636d5 |
comparison
equal
deleted
inserted
replaced
10109:3edc6b14299b | 10110:cfb38b57d407 |
---|---|
500 else | 500 else |
501 #endif | 501 #endif |
502 retval = lnum - cursor; | 502 retval = lnum - cursor; |
503 | 503 |
504 return retval; | 504 return retval; |
505 } | |
506 | |
507 /* | |
508 * Make sure "pos.lnum" and "pos.col" are valid in "buf". | |
509 * This allows for the col to be on the NUL byte. | |
510 */ | |
511 void | |
512 check_pos(buf_T *buf, pos_T *pos) | |
513 { | |
514 char_u *line; | |
515 colnr_T len; | |
516 | |
517 if (pos->lnum > buf->b_ml.ml_line_count) | |
518 pos->lnum = buf->b_ml.ml_line_count; | |
519 | |
520 if (pos->col > 0) | |
521 { | |
522 line = ml_get_buf(buf, pos->lnum, FALSE); | |
523 len = (colnr_T)STRLEN(line); | |
524 if (pos->col > len) | |
525 pos->col = len; | |
526 } | |
505 } | 527 } |
506 | 528 |
507 /* | 529 /* |
508 * Make sure curwin->w_cursor.lnum is valid. | 530 * Make sure curwin->w_cursor.lnum is valid. |
509 */ | 531 */ |