components/vim/vim72-patches/7.2.125
changeset 198 172fc01ce997
equal deleted inserted replaced
197:fd801ec0737c 198:172fc01ce997
       
     1 To: [email protected]
       
     2 Subject: Patch 7.2.125
       
     3 Fcc: outbox
       
     4 From: Bram Moolenaar <[email protected]>
       
     5 Mime-Version: 1.0
       
     6 Content-Type: text/plain; charset=ISO-8859-1
       
     7 Content-Transfer-Encoding: 8bit
       
     8 ------------
       
     9 
       
    10 Patch 7.2.125
       
    11 Problem:    Leaking memory when reading XPM bitmap for a sign.
       
    12 Solution:   Don't allocate the memory twice. (Dominique Pelle)
       
    13 Files:      src/gui_x11.c
       
    14 
       
    15 
       
    16 *** ../vim-7.2.124/src/gui_x11.c	Wed Nov 12 13:07:48 2008
       
    17 --- src/gui_x11.c	Sun Feb 22 21:58:19 2009
       
    18 ***************
       
    19 *** 1587,1592 ****
       
    20 --- 1587,1594 ----
       
    21       XtCloseDisplay(gui.dpy);
       
    22       gui.dpy = NULL;
       
    23       vimShell = (Widget)0;
       
    24 +     vim_free(gui_argv);
       
    25 +     gui_argv = NULL;
       
    26   }
       
    27   
       
    28   /*
       
    29 ***************
       
    30 *** 1761,1766 ****
       
    31 --- 1763,1770 ----
       
    32        * says that this isn't needed when exiting, so just skip it. */
       
    33       XtCloseDisplay(gui.dpy);
       
    34   #endif
       
    35 +     vim_free(gui_argv);
       
    36 +     gui_argv = NULL;
       
    37   }
       
    38   
       
    39   /*
       
    40 ***************
       
    41 *** 3439,3485 ****
       
    42       char_u	    *signfile;
       
    43   {
       
    44       XpmAttributes   attrs;
       
    45 !     XImage	    *sign;
       
    46       int		    status;
       
    47   
       
    48       /*
       
    49        * Setup the color substitution table.
       
    50        */
       
    51 -     sign = NULL;
       
    52       if (signfile[0] != NUL && signfile[0] != '-')
       
    53       {
       
    54 ! 	sign = (XImage *)alloc(sizeof(XImage));
       
    55 ! 	if (sign != NULL)
       
    56   	{
       
    57 ! 	    XpmColorSymbol color[5] =
       
    58 ! 	    {
       
    59 ! 		{"none", NULL, 0},
       
    60 ! 		{"iconColor1", NULL, 0},
       
    61 ! 		{"bottomShadowColor", NULL, 0},
       
    62 ! 		{"topShadowColor", NULL, 0},
       
    63 ! 		{"selectColor", NULL, 0}
       
    64 ! 	    };
       
    65 ! 	    attrs.valuemask = XpmColorSymbols;
       
    66 ! 	    attrs.numsymbols = 2;
       
    67 ! 	    attrs.colorsymbols = color;
       
    68 ! 	    attrs.colorsymbols[0].pixel = gui.back_pixel;
       
    69 ! 	    attrs.colorsymbols[1].pixel = gui.norm_pixel;
       
    70 ! 	    status = XpmReadFileToImage(gui.dpy, (char *)signfile,
       
    71   							 &sign, NULL, &attrs);
       
    72 ! 
       
    73 ! 	    if (status == 0)
       
    74 ! 	    {
       
    75 ! 		/* Sign width is fixed at two columns now.
       
    76 ! 		if (sign->width > gui.sign_width)
       
    77 ! 		    gui.sign_width = sign->width + 8; */
       
    78 ! 	    }
       
    79 ! 	    else
       
    80 ! 	    {
       
    81 ! 		vim_free(sign);
       
    82 ! 		sign = NULL;
       
    83 ! 		EMSG(_(e_signdata));
       
    84 ! 	    }
       
    85   	}
       
    86       }
       
    87   
       
    88       return (void *)sign;
       
    89 --- 3443,3479 ----
       
    90       char_u	    *signfile;
       
    91   {
       
    92       XpmAttributes   attrs;
       
    93 !     XImage	    *sign = NULL;
       
    94       int		    status;
       
    95   
       
    96       /*
       
    97        * Setup the color substitution table.
       
    98        */
       
    99       if (signfile[0] != NUL && signfile[0] != '-')
       
   100       {
       
   101 ! 	XpmColorSymbol color[5] =
       
   102   	{
       
   103 ! 	    {"none", NULL, 0},
       
   104 ! 	    {"iconColor1", NULL, 0},
       
   105 ! 	    {"bottomShadowColor", NULL, 0},
       
   106 ! 	    {"topShadowColor", NULL, 0},
       
   107 ! 	    {"selectColor", NULL, 0}
       
   108 ! 	};
       
   109 ! 	attrs.valuemask = XpmColorSymbols;
       
   110 ! 	attrs.numsymbols = 2;
       
   111 ! 	attrs.colorsymbols = color;
       
   112 ! 	attrs.colorsymbols[0].pixel = gui.back_pixel;
       
   113 ! 	attrs.colorsymbols[1].pixel = gui.norm_pixel;
       
   114 ! 	status = XpmReadFileToImage(gui.dpy, (char *)signfile,
       
   115   							 &sign, NULL, &attrs);
       
   116 ! 	if (status == 0)
       
   117 ! 	{
       
   118 ! 	    /* Sign width is fixed at two columns now.
       
   119 ! 	    if (sign->width > gui.sign_width)
       
   120 ! 	        gui.sign_width = sign->width + 8; */
       
   121   	}
       
   122 + 	else
       
   123 + 	    EMSG(_(e_signdata));
       
   124       }
       
   125   
       
   126       return (void *)sign;
       
   127 ***************
       
   128 *** 3489,3496 ****
       
   129   gui_mch_destroy_sign(sign)
       
   130       void *sign;
       
   131   {
       
   132 !     XFree(((XImage *)sign)->data);
       
   133 !     vim_free(sign);
       
   134   }
       
   135   #endif
       
   136   
       
   137 --- 3483,3489 ----
       
   138   gui_mch_destroy_sign(sign)
       
   139       void *sign;
       
   140   {
       
   141 !     XDestroyImage((XImage*)sign);
       
   142   }
       
   143   #endif
       
   144   
       
   145 *** ../vim-7.2.124/src/version.c	Mon Feb 23 00:53:35 2009
       
   146 --- src/version.c	Tue Feb 24 04:09:33 2009
       
   147 ***************
       
   148 *** 678,679 ****
       
   149 --- 678,681 ----
       
   150   {   /* Add new patch number below this line */
       
   151 + /**/
       
   152 +     125,
       
   153   /**/
       
   154 
       
   155 -- 
       
   156 I have a watch cat! Just break in and she'll watch.
       
   157 
       
   158  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
       
   159 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
       
   160 \\\        download, build and distribute -- http://www.A-A-P.org        ///
       
   161  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///