Patch 7.4.2326
Problem:    Illegal memory access when Visual selection starts in invalid
            position. (Dominique Pelle)
Solution:   Correct position when needed.
Files:      src/normal.c, src/misc2.c, src/proto/misc2.pro


*** ../vim-7.4.2325/src/normal.c        2016-09-03 21:04:54.993247355 +0200
--- src/normal.c        2016-09-04 20:18:29.415509068 +0200
***************
*** 9451,9457 ****
--- 9451,9460 ----
  #ifdef FEAT_MBYTE
      /* prevent from moving onto a trail byte */
      if (has_mbyte)
+     {
+       check_pos(curwin->w_buffer, &oap->end);
        mb_adjustpos(curwin->w_buffer, &oap->end);
+     }
  #endif
  
      getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol);
*** ../vim-7.4.2325/src/misc2.c 2016-08-29 22:48:12.153106148 +0200
--- src/misc2.c 2016-09-04 20:34:12.939884024 +0200
***************
*** 505,510 ****
--- 505,532 ----
  }
  
  /*
+  * Make sure "pos.lnum" and "pos.col" are valid in "buf".
+  * This allows for the col to be on the NUL byte.
+  */
+     void
+ check_pos(buf_T *buf, pos_T *pos)
+ {
+     char_u *line;
+     colnr_T len;
+ 
+     if (pos->lnum > buf->b_ml.ml_line_count)
+       pos->lnum = buf->b_ml.ml_line_count;
+ 
+     if (pos->col > 0)
+     {
+       line = ml_get_buf(buf, pos->lnum, FALSE);
+       len = (colnr_T)STRLEN(line);
+       if (pos->col > len)
+           pos->col = len;
+     }
+ }
+ 
+ /*
   * Make sure curwin->w_cursor.lnum is valid.
   */
      void
*** ../vim-7.4.2325/src/proto/misc2.pro 2016-08-14 16:07:44.721705396 +0200
--- src/proto/misc2.pro 2016-09-04 20:26:28.959636641 +0200
***************
*** 12,17 ****
--- 12,18 ----
  int dec(pos_T *lp);
  int decl(pos_T *lp);
  linenr_T get_cursor_rel_lnum(win_T *wp, linenr_T lnum);
+ void check_pos(buf_T *buf, pos_T *pos);
  void check_cursor_lnum(void);
  void check_cursor_col(void);
  void check_cursor_col_win(win_T *win);
*** ../vim-7.4.2325/src/version.c       2016-09-04 19:57:53.193539060 +0200
--- src/version.c       2016-09-04 20:34:33.999713568 +0200
***************
*** 765,766 ****
--- 765,768 ----
  {   /* Add new patch number below this line */
+ /**/
+     2326,
  /**/

-- 
Microsoft says that MS-Windows is much better for you than Linux.
That's like the Pope saying that catholicism is much better for
you than protestantism.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui