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