From 6588f1bd9bd41af8ce0157298eafec8f47780ff4 Mon Sep 17 00:00:00 2001 From: Karsten Hopp Date: May 08 2013 15:06:44 +0000 Subject: - patchlevel 916 --- diff --git a/7.3.916 b/7.3.916 new file mode 100644 index 0000000..3ed5ec1 --- /dev/null +++ b/7.3.916 @@ -0,0 +1,115 @@ +To: vim_dev@googlegroups.com +Subject: Patch 7.3.916 +Fcc: outbox +From: Bram Moolenaar +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 7.3.916 +Problem: Using freed memory when pasting with the mouse (Issue 130). +Solution: Get the byte value early. (hint by Dominique Pelle) +Files: src/buffer.c + + +*** ../vim-7.3.915/src/buffer.c 2013-04-15 12:27:30.000000000 +0200 +--- src/buffer.c 2013-04-24 16:45:38.000000000 +0200 +*************** +*** 3506,3512 **** + char_u *p; + char_u *s; + char_u *t; +! char_u *linecont; + #ifdef FEAT_EVAL + win_T *o_curwin; + buf_T *o_curbuf; +--- 3506,3512 ---- + char_u *p; + char_u *s; + char_u *t; +! int byteval; + #ifdef FEAT_EVAL + win_T *o_curwin; + buf_T *o_curbuf; +*************** +*** 3573,3584 **** + fillchar = '-'; + #endif + +! /* +! * Get line & check if empty (cursorpos will show "0-1"). +! * If inversion is possible we use it. Else '=' characters are used. +! */ +! linecont = ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE); +! empty_line = (*linecont == NUL); + + groupdepth = 0; + p = out; +--- 3573,3593 ---- + fillchar = '-'; + #endif + +! /* Get line & check if empty (cursorpos will show "0-1"). Note that +! * p will become invalid when getting another buffer line. */ +! p = ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE); +! empty_line = (*p == NUL); +! +! /* Get the byte value now, in case we need it below. This is more +! * efficient than making a copy of the line. */ +! if (wp->w_cursor.col > (colnr_T)STRLEN(p)) +! byteval = 0; +! else +! #ifdef FEAT_MBYTE +! byteval = (*mb_ptr2char)(p + wp->w_cursor.col); +! #else +! byteval = p[wp->w_cursor.col]; +! #endif + + groupdepth = 0; + p = out; +*************** +*** 3956,3971 **** + case STL_BYTEVAL_X: + base = 'X'; + case STL_BYTEVAL: +! if (wp->w_cursor.col > (colnr_T)STRLEN(linecont)) +! num = 0; +! else +! { +! #ifdef FEAT_MBYTE +! num = (*mb_ptr2char)(linecont + wp->w_cursor.col); +! #else +! num = linecont[wp->w_cursor.col]; +! #endif +! } + if (num == NL) + num = 0; + else if (num == CAR && get_fileformat(wp->w_buffer) == EOL_MAC) +--- 3965,3971 ---- + case STL_BYTEVAL_X: + base = 'X'; + case STL_BYTEVAL: +! num = byteval; + if (num == NL) + num = 0; + else if (num == CAR && get_fileformat(wp->w_buffer) == EOL_MAC) +*** ../vim-7.3.915/src/version.c 2013-04-24 16:33:58.000000000 +0200 +--- src/version.c 2013-04-24 16:51:24.000000000 +0200 +*************** +*** 730,731 **** +--- 730,733 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 916, + /**/ + +-- +hundred-and-one symptoms of being an internet addict: +228. You spend Saturday night making the counter on your home page + pass that 2000 mark. + + /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///