073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.528
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.528
073263
Problem:    Crash when using matchadd() (Yasuhiro Matsumoto)
073263
Solution:   Copy the match regprog.
073263
Files:	    src/screen.c
073263
073263
073263
*** ../vim-7.4.527/src/screen.c	2014-11-19 13:21:24.984724043 +0100
073263
--- src/screen.c	2014-11-27 13:26:05.754837048 +0100
073263
***************
073263
*** 7588,7593 ****
073263
--- 7588,7599 ----
073263
  	shl->lnum = lnum;
073263
  	if (shl->rm.regprog != NULL)
073263
  	{
073263
+ 	    /* Remember whether shl->rm is using a copy of the regprog in
073263
+ 	     * cur->match. */
073263
+ 	    int regprog_is_copy = (shl != &search_hl && cur != NULL
073263
+ 				&& shl == &cur->hl
073263
+ 				&& cur->match.regprog == cur->hl.rm.regprog);
073263
+ 
073263
  	    nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum,
073263
  		    matchcol,
073263
  #ifdef FEAT_RELTIME
073263
***************
073263
*** 7596,7601 ****
073263
--- 7602,7611 ----
073263
  		    NULL
073263
  #endif
073263
  		    );
073263
+ 	    /* Copy the regprog, in case it got freed and recompiled. */
073263
+ 	    if (regprog_is_copy)
073263
+ 		cur->match.regprog = cur->hl.rm.regprog;
073263
+ 
073263
  	    if (called_emsg || got_int)
073263
  	    {
073263
  		/* Error while handling regexp: stop using this regexp. */
073263
*** ../vim-7.4.527/src/version.c	2014-11-23 15:57:45.568009419 +0100
073263
--- src/version.c	2014-11-27 13:28:07.393495013 +0100
073263
***************
073263
*** 743,744 ****
073263
--- 743,746 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     528,
073263
  /**/
073263
073263
-- 
073263
FATAL ERROR! SYSTEM HALTED! - Press any key to continue doing nothing.
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///