a856f41
To: vim-dev@vim.org
a856f41
Subject: Patch 7.2.125
a856f41
Fcc: outbox
a856f41
From: Bram Moolenaar <Bram@moolenaar.net>
a856f41
Mime-Version: 1.0
a856f41
Content-Type: text/plain; charset=ISO-8859-1
a856f41
Content-Transfer-Encoding: 8bit
a856f41
------------
a856f41
a856f41
Patch 7.2.125
a856f41
Problem:    Leaking memory when reading XPM bitmap for a sign.
a856f41
Solution:   Don't allocate the memory twice. (Dominique Pelle)
a856f41
Files:      src/gui_x11.c
a856f41
a856f41
a856f41
*** ../vim-7.2.124/src/gui_x11.c	Wed Nov 12 13:07:48 2008
a856f41
--- src/gui_x11.c	Sun Feb 22 21:58:19 2009
a856f41
***************
a856f41
*** 1587,1592 ****
a856f41
--- 1587,1594 ----
a856f41
      XtCloseDisplay(gui.dpy);
a856f41
      gui.dpy = NULL;
a856f41
      vimShell = (Widget)0;
a856f41
+     vim_free(gui_argv);
a856f41
+     gui_argv = NULL;
a856f41
  }
a856f41
  
a856f41
  /*
a856f41
***************
a856f41
*** 1761,1766 ****
a856f41
--- 1763,1770 ----
a856f41
       * says that this isn't needed when exiting, so just skip it. */
a856f41
      XtCloseDisplay(gui.dpy);
a856f41
  #endif
a856f41
+     vim_free(gui_argv);
a856f41
+     gui_argv = NULL;
a856f41
  }
a856f41
  
a856f41
  /*
a856f41
***************
a856f41
*** 3439,3485 ****
a856f41
      char_u	    *signfile;
a856f41
  {
a856f41
      XpmAttributes   attrs;
a856f41
!     XImage	    *sign;
a856f41
      int		    status;
a856f41
  
a856f41
      /*
a856f41
       * Setup the color substitution table.
a856f41
       */
a856f41
-     sign = NULL;
a856f41
      if (signfile[0] != NUL && signfile[0] != '-')
a856f41
      {
a856f41
! 	sign = (XImage *)alloc(sizeof(XImage));
a856f41
! 	if (sign != NULL)
a856f41
  	{
a856f41
! 	    XpmColorSymbol color[5] =
a856f41
! 	    {
a856f41
! 		{"none", NULL, 0},
a856f41
! 		{"iconColor1", NULL, 0},
a856f41
! 		{"bottomShadowColor", NULL, 0},
a856f41
! 		{"topShadowColor", NULL, 0},
a856f41
! 		{"selectColor", NULL, 0}
a856f41
! 	    };
a856f41
! 	    attrs.valuemask = XpmColorSymbols;
a856f41
! 	    attrs.numsymbols = 2;
a856f41
! 	    attrs.colorsymbols = color;
a856f41
! 	    attrs.colorsymbols[0].pixel = gui.back_pixel;
a856f41
! 	    attrs.colorsymbols[1].pixel = gui.norm_pixel;
a856f41
! 	    status = XpmReadFileToImage(gui.dpy, (char *)signfile,
a856f41
  							 &sign, NULL, &attrs);
a856f41
! 
a856f41
! 	    if (status == 0)
a856f41
! 	    {
a856f41
! 		/* Sign width is fixed at two columns now.
a856f41
! 		if (sign->width > gui.sign_width)
a856f41
! 		    gui.sign_width = sign->width + 8; */
a856f41
! 	    }
a856f41
! 	    else
a856f41
! 	    {
a856f41
! 		vim_free(sign);
a856f41
! 		sign = NULL;
a856f41
! 		EMSG(_(e_signdata));
a856f41
! 	    }
a856f41
  	}
a856f41
      }
a856f41
  
a856f41
      return (void *)sign;
a856f41
--- 3443,3479 ----
a856f41
      char_u	    *signfile;
a856f41
  {
a856f41
      XpmAttributes   attrs;
a856f41
!     XImage	    *sign = NULL;
a856f41
      int		    status;
a856f41
  
a856f41
      /*
a856f41
       * Setup the color substitution table.
a856f41
       */
a856f41
      if (signfile[0] != NUL && signfile[0] != '-')
a856f41
      {
a856f41
! 	XpmColorSymbol color[5] =
a856f41
  	{
a856f41
! 	    {"none", NULL, 0},
a856f41
! 	    {"iconColor1", NULL, 0},
a856f41
! 	    {"bottomShadowColor", NULL, 0},
a856f41
! 	    {"topShadowColor", NULL, 0},
a856f41
! 	    {"selectColor", NULL, 0}
a856f41
! 	};
a856f41
! 	attrs.valuemask = XpmColorSymbols;
a856f41
! 	attrs.numsymbols = 2;
a856f41
! 	attrs.colorsymbols = color;
a856f41
! 	attrs.colorsymbols[0].pixel = gui.back_pixel;
a856f41
! 	attrs.colorsymbols[1].pixel = gui.norm_pixel;
a856f41
! 	status = XpmReadFileToImage(gui.dpy, (char *)signfile,
a856f41
  							 &sign, NULL, &attrs);
a856f41
! 	if (status == 0)
a856f41
! 	{
a856f41
! 	    /* Sign width is fixed at two columns now.
a856f41
! 	    if (sign->width > gui.sign_width)
a856f41
! 	        gui.sign_width = sign->width + 8; */
a856f41
  	}
a856f41
+ 	else
a856f41
+ 	    EMSG(_(e_signdata));
a856f41
      }
a856f41
  
a856f41
      return (void *)sign;
a856f41
***************
a856f41
*** 3489,3496 ****
a856f41
  gui_mch_destroy_sign(sign)
a856f41
      void *sign;
a856f41
  {
a856f41
!     XFree(((XImage *)sign)->data);
a856f41
!     vim_free(sign);
a856f41
  }
a856f41
  #endif
a856f41
  
a856f41
--- 3483,3489 ----
a856f41
  gui_mch_destroy_sign(sign)
a856f41
      void *sign;
a856f41
  {
a856f41
!     XDestroyImage((XImage*)sign);
a856f41
  }
a856f41
  #endif
a856f41
  
a856f41
*** ../vim-7.2.124/src/version.c	Mon Feb 23 00:53:35 2009
a856f41
--- src/version.c	Tue Feb 24 04:09:33 2009
a856f41
***************
a856f41
*** 678,679 ****
a856f41
--- 678,681 ----
a856f41
  {   /* Add new patch number below this line */
a856f41
+ /**/
a856f41
+     125,
a856f41
  /**/
a856f41
a856f41
-- 
a856f41
I have a watch cat! Just break in and she'll watch.
a856f41
a856f41
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
a856f41
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
a856f41
\\\        download, build and distribute -- http://www.A-A-P.org        ///
a856f41
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///