Blob Blame History Raw
To: vim-dev@vim.org
Subject: Patch 7.2.125
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.125
Problem:    Leaking memory when reading XPM bitmap for a sign.
Solution:   Don't allocate the memory twice. (Dominique Pelle)
Files:      src/gui_x11.c


*** ../vim-7.2.124/src/gui_x11.c	Wed Nov 12 13:07:48 2008
--- src/gui_x11.c	Sun Feb 22 21:58:19 2009
***************
*** 1587,1592 ****
--- 1587,1594 ----
      XtCloseDisplay(gui.dpy);
      gui.dpy = NULL;
      vimShell = (Widget)0;
+     vim_free(gui_argv);
+     gui_argv = NULL;
  }
  
  /*
***************
*** 1761,1766 ****
--- 1763,1770 ----
       * says that this isn't needed when exiting, so just skip it. */
      XtCloseDisplay(gui.dpy);
  #endif
+     vim_free(gui_argv);
+     gui_argv = NULL;
  }
  
  /*
***************
*** 3439,3485 ****
      char_u	    *signfile;
  {
      XpmAttributes   attrs;
!     XImage	    *sign;
      int		    status;
  
      /*
       * Setup the color substitution table.
       */
-     sign = NULL;
      if (signfile[0] != NUL && signfile[0] != '-')
      {
! 	sign = (XImage *)alloc(sizeof(XImage));
! 	if (sign != NULL)
  	{
! 	    XpmColorSymbol color[5] =
! 	    {
! 		{"none", NULL, 0},
! 		{"iconColor1", NULL, 0},
! 		{"bottomShadowColor", NULL, 0},
! 		{"topShadowColor", NULL, 0},
! 		{"selectColor", NULL, 0}
! 	    };
! 	    attrs.valuemask = XpmColorSymbols;
! 	    attrs.numsymbols = 2;
! 	    attrs.colorsymbols = color;
! 	    attrs.colorsymbols[0].pixel = gui.back_pixel;
! 	    attrs.colorsymbols[1].pixel = gui.norm_pixel;
! 	    status = XpmReadFileToImage(gui.dpy, (char *)signfile,
  							 &sign, NULL, &attrs);
! 
! 	    if (status == 0)
! 	    {
! 		/* Sign width is fixed at two columns now.
! 		if (sign->width > gui.sign_width)
! 		    gui.sign_width = sign->width + 8; */
! 	    }
! 	    else
! 	    {
! 		vim_free(sign);
! 		sign = NULL;
! 		EMSG(_(e_signdata));
! 	    }
  	}
      }
  
      return (void *)sign;
--- 3443,3479 ----
      char_u	    *signfile;
  {
      XpmAttributes   attrs;
!     XImage	    *sign = NULL;
      int		    status;
  
      /*
       * Setup the color substitution table.
       */
      if (signfile[0] != NUL && signfile[0] != '-')
      {
! 	XpmColorSymbol color[5] =
  	{
! 	    {"none", NULL, 0},
! 	    {"iconColor1", NULL, 0},
! 	    {"bottomShadowColor", NULL, 0},
! 	    {"topShadowColor", NULL, 0},
! 	    {"selectColor", NULL, 0}
! 	};
! 	attrs.valuemask = XpmColorSymbols;
! 	attrs.numsymbols = 2;
! 	attrs.colorsymbols = color;
! 	attrs.colorsymbols[0].pixel = gui.back_pixel;
! 	attrs.colorsymbols[1].pixel = gui.norm_pixel;
! 	status = XpmReadFileToImage(gui.dpy, (char *)signfile,
  							 &sign, NULL, &attrs);
! 	if (status == 0)
! 	{
! 	    /* Sign width is fixed at two columns now.
! 	    if (sign->width > gui.sign_width)
! 	        gui.sign_width = sign->width + 8; */
  	}
+ 	else
+ 	    EMSG(_(e_signdata));
      }
  
      return (void *)sign;
***************
*** 3489,3496 ****
  gui_mch_destroy_sign(sign)
      void *sign;
  {
!     XFree(((XImage *)sign)->data);
!     vim_free(sign);
  }
  #endif
  
--- 3483,3489 ----
  gui_mch_destroy_sign(sign)
      void *sign;
  {
!     XDestroyImage((XImage*)sign);
  }
  #endif
  
*** ../vim-7.2.124/src/version.c	Mon Feb 23 00:53:35 2009
--- src/version.c	Tue Feb 24 04:09:33 2009
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     125,
  /**/

-- 
I have a watch cat! Just break in and she'll watch.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///