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