Karsten Hopp e0eb01
To: vim-dev@vim.org
Karsten Hopp e0eb01
Subject: patch 7.0.200
Karsten Hopp e0eb01
Fcc: outbox
Karsten Hopp e0eb01
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp e0eb01
Mime-Version: 1.0
Karsten Hopp e0eb01
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp e0eb01
Content-Transfer-Encoding: 8bit
Karsten Hopp e0eb01
------------
Karsten Hopp e0eb01
Karsten Hopp e0eb01
Patch 7.0.200
Karsten Hopp e0eb01
Problem:    Memory leaks when out of memory.
Karsten Hopp e0eb01
Solution:   Free the memory.
Karsten Hopp e0eb01
Files:      src/edit.c, src/diff.c
Karsten Hopp e0eb01
Karsten Hopp e0eb01
Karsten Hopp e0eb01
*** ../vim-7.0.199/src/edit.c	Tue Feb 20 03:33:51 2007
Karsten Hopp e0eb01
--- src/edit.c	Fri Feb 16 01:15:49 2007
Karsten Hopp e0eb01
***************
Karsten Hopp e0eb01
*** 2698,2703 ****
Karsten Hopp e0eb01
--- 2698,2704 ----
Karsten Hopp e0eb01
      buf = alloc(LSIZE);
Karsten Hopp e0eb01
      if (buf == NULL)
Karsten Hopp e0eb01
  	return;
Karsten Hopp e0eb01
+     regmatch.regprog = NULL;	/* so that we can goto theend */
Karsten Hopp e0eb01
  
Karsten Hopp e0eb01
      /* If 'infercase' is set, don't use 'smartcase' here */
Karsten Hopp e0eb01
      save_p_scs = p_scs;
Karsten Hopp e0eb01
***************
Karsten Hopp e0eb01
*** 2712,2724 ****
Karsten Hopp e0eb01
  	char_u *pat_esc = vim_strsave_escaped(pat, (char_u *)"\\");
Karsten Hopp e0eb01
  
Karsten Hopp e0eb01
  	if (pat_esc == NULL)
Karsten Hopp e0eb01
! 	    return ;
Karsten Hopp e0eb01
  	i = (int)STRLEN(pat_esc) + 10;
Karsten Hopp e0eb01
  	ptr = alloc(i);
Karsten Hopp e0eb01
  	if (ptr == NULL)
Karsten Hopp e0eb01
  	{
Karsten Hopp e0eb01
  	    vim_free(pat_esc);
Karsten Hopp e0eb01
! 	    return;
Karsten Hopp e0eb01
  	}
Karsten Hopp e0eb01
  	vim_snprintf((char *)ptr, i, "^\\s*\\zs\\V%s", pat_esc);
Karsten Hopp e0eb01
  	regmatch.regprog = vim_regcomp(ptr, RE_MAGIC);
Karsten Hopp e0eb01
--- 2713,2725 ----
Karsten Hopp e0eb01
  	char_u *pat_esc = vim_strsave_escaped(pat, (char_u *)"\\");
Karsten Hopp e0eb01
  
Karsten Hopp e0eb01
  	if (pat_esc == NULL)
Karsten Hopp e0eb01
! 	    goto theend ;
Karsten Hopp e0eb01
  	i = (int)STRLEN(pat_esc) + 10;
Karsten Hopp e0eb01
  	ptr = alloc(i);
Karsten Hopp e0eb01
  	if (ptr == NULL)
Karsten Hopp e0eb01
  	{
Karsten Hopp e0eb01
  	    vim_free(pat_esc);
Karsten Hopp e0eb01
! 	    goto theend;
Karsten Hopp e0eb01
  	}
Karsten Hopp e0eb01
  	vim_snprintf((char *)ptr, i, "^\\s*\\zs\\V%s", pat_esc);
Karsten Hopp e0eb01
  	regmatch.regprog = vim_regcomp(ptr, RE_MAGIC);
Karsten Hopp e0eb01
*** ../vim-7.0.199/src/diff.c	Sun Apr 23 00:23:34 2006
Karsten Hopp e0eb01
--- src/diff.c	Fri Feb 16 01:18:41 2007
Karsten Hopp e0eb01
***************
Karsten Hopp e0eb01
*** 1822,1835 ****
Karsten Hopp e0eb01
--- 1822,1841 ----
Karsten Hopp e0eb01
  
Karsten Hopp e0eb01
      idx = diff_buf_idx(wp->w_buffer);
Karsten Hopp e0eb01
      if (idx == DB_COUNT)	/* cannot happen */
Karsten Hopp e0eb01
+     {
Karsten Hopp e0eb01
+ 	vim_free(line_org);
Karsten Hopp e0eb01
  	return FALSE;
Karsten Hopp e0eb01
+     }
Karsten Hopp e0eb01
  
Karsten Hopp e0eb01
      /* search for a change that includes "lnum" in the list of diffblocks. */
Karsten Hopp e0eb01
      for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
Karsten Hopp e0eb01
  	if (lnum <= dp->df_lnum[idx] + dp->df_count[idx])
Karsten Hopp e0eb01
  	    break;
Karsten Hopp e0eb01
      if (dp == NULL || diff_check_sanity(curtab, dp) == FAIL)
Karsten Hopp e0eb01
+     {
Karsten Hopp e0eb01
+ 	vim_free(line_org);
Karsten Hopp e0eb01
  	return FALSE;
Karsten Hopp e0eb01
+     }
Karsten Hopp e0eb01
  
Karsten Hopp e0eb01
      off = lnum - dp->df_lnum[idx];
Karsten Hopp e0eb01
  
Karsten Hopp e0eb01
*** ../vim-7.0.199/src/version.c	Tue Feb 20 03:33:51 2007
Karsten Hopp e0eb01
--- src/version.c	Tue Feb 20 03:48:16 2007
Karsten Hopp e0eb01
***************
Karsten Hopp e0eb01
*** 668,669 ****
Karsten Hopp e0eb01
--- 668,671 ----
Karsten Hopp e0eb01
  {   /* Add new patch number below this line */
Karsten Hopp e0eb01
+ /**/
Karsten Hopp e0eb01
+     200,
Karsten Hopp e0eb01
  /**/
Karsten Hopp e0eb01
Karsten Hopp e0eb01
-- 
Karsten Hopp e0eb01
hundred-and-one symptoms of being an internet addict:
Karsten Hopp e0eb01
157. You fum through a magazine, you first check to see if it has a web
Karsten Hopp e0eb01
     address.
Karsten Hopp e0eb01
Karsten Hopp e0eb01
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp e0eb01
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp e0eb01
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp e0eb01
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///