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