home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.2 / 7.2.125 < prev    next >
Encoding:
Internet Message Format  |  2009-02-23  |  3.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 7.2.125
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  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. !         if (status == 0)
  73. !         {
  74. !         /* Sign width is fixed at two columns now.
  75. !         if (sign->width > gui.sign_width)
  76. !             gui.sign_width = sign->width + 8; */
  77. !         }
  78. !         else
  79. !         {
  80. !         vim_free(sign);
  81. !         sign = NULL;
  82. !         EMSG(_(e_signdata));
  83. !         }
  84.       }
  85.       }
  86.   
  87.       return (void *)sign;
  88. --- 3443,3479 ----
  89.       char_u        *signfile;
  90.   {
  91.       XpmAttributes   attrs;
  92. !     XImage        *sign = NULL;
  93.       int            status;
  94.   
  95.       /*
  96.        * Setup the color substitution table.
  97.        */
  98.       if (signfile[0] != NUL && signfile[0] != '-')
  99.       {
  100. !     XpmColorSymbol color[5] =
  101.       {
  102. !         {"none", NULL, 0},
  103. !         {"iconColor1", NULL, 0},
  104. !         {"bottomShadowColor", NULL, 0},
  105. !         {"topShadowColor", NULL, 0},
  106. !         {"selectColor", NULL, 0}
  107. !     };
  108. !     attrs.valuemask = XpmColorSymbols;
  109. !     attrs.numsymbols = 2;
  110. !     attrs.colorsymbols = color;
  111. !     attrs.colorsymbols[0].pixel = gui.back_pixel;
  112. !     attrs.colorsymbols[1].pixel = gui.norm_pixel;
  113. !     status = XpmReadFileToImage(gui.dpy, (char *)signfile,
  114.                                &sign, NULL, &attrs);
  115. !     if (status == 0)
  116. !     {
  117. !         /* Sign width is fixed at two columns now.
  118. !         if (sign->width > gui.sign_width)
  119. !             gui.sign_width = sign->width + 8; */
  120.       }
  121. +     else
  122. +         EMSG(_(e_signdata));
  123.       }
  124.   
  125.       return (void *)sign;
  126. ***************
  127. *** 3489,3496 ****
  128.   gui_mch_destroy_sign(sign)
  129.       void *sign;
  130.   {
  131. !     XFree(((XImage *)sign)->data);
  132. !     vim_free(sign);
  133.   }
  134.   #endif
  135.   
  136. --- 3483,3489 ----
  137.   gui_mch_destroy_sign(sign)
  138.       void *sign;
  139.   {
  140. !     XDestroyImage((XImage*)sign);
  141.   }
  142.   #endif
  143.   
  144. *** ../vim-7.2.124/src/version.c    Mon Feb 23 00:53:35 2009
  145. --- src/version.c    Tue Feb 24 04:09:33 2009
  146. ***************
  147. *** 678,679 ****
  148. --- 678,681 ----
  149.   {   /* Add new patch number below this line */
  150. + /**/
  151. +     125,
  152.   /**/
  153.  
  154. -- 
  155. I have a watch cat! Just break in and she'll watch.
  156.  
  157.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  158. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  159. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  160.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  161.