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 / 6.0.184 < prev    next >
Encoding:
Internet Message Format  |  2002-02-03  |  2.9 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.184
  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 6.0.184
  11. Problem:    Leaking memory when expanding option values.
  12. Solution:   Don't always copy the expanded option into allocated memory.
  13. Files:        src/option.c
  14.  
  15.  
  16. *** ../vim60.183/src/option.c    Wed Jan 30 16:50:08 2002
  17. --- src/option.c    Mon Feb  4 22:17:17 2002
  18. ***************
  19. *** 3460,3467 ****
  20.                   {
  21.                   s = option_expand(opt_idx, newval);
  22.                   if (s == NULL)
  23. !                     s = vim_strsave(newval);
  24. !                 newval = s;
  25.                   }
  26.                   new_value_alloced = TRUE;
  27.               }
  28. --- 3460,3467 ----
  29.                   {
  30.                   s = option_expand(opt_idx, newval);
  31.                   if (s == NULL)
  32. !                     s = newval;
  33. !                 newval = vim_strsave(s);
  34.                   }
  35.                   new_value_alloced = TRUE;
  36.               }
  37. ***************
  38. *** 3955,3961 ****
  39.    * Expand environment variables for some string options.
  40.    * These string options cannot be indirect!
  41.    * If "val" is NULL expand the current value of the option.
  42. !  * Return pointer to allocated memory, or NULL when not expanded.
  43.    */
  44.       static char_u *
  45.   option_expand(opt_idx, val)
  46. --- 3955,3961 ----
  47.    * Expand environment variables for some string options.
  48.    * These string options cannot be indirect!
  49.    * If "val" is NULL expand the current value of the option.
  50. !  * Return pointer to NameBuff, or NULL when not expanded.
  51.    */
  52.       static char_u *
  53.   option_expand(opt_idx, val)
  54. ***************
  55. *** 3967,3973 ****
  56.       return NULL;
  57.   
  58.       /* If val is longer than MAXPATHL no meaningful expansion can be done,
  59. !      * expand_env would truncate the string. */
  60.       if (val != NULL && STRLEN(val) > MAXPATHL)
  61.       return NULL;
  62.   
  63. --- 3967,3973 ----
  64.       return NULL;
  65.   
  66.       /* If val is longer than MAXPATHL no meaningful expansion can be done,
  67. !      * expand_env() would truncate the string. */
  68.       if (val != NULL && STRLEN(val) > MAXPATHL)
  69.       return NULL;
  70.   
  71. ***************
  72. *** 3981,3987 ****
  73.       if (STRCMP(NameBuff, val) == 0)   /* they are the same */
  74.       return NULL;
  75.   
  76. !     return vim_strsave(NameBuff);
  77.   }
  78.   
  79.   /*
  80. --- 3981,3987 ----
  81.       if (STRCMP(NameBuff, val) == 0)   /* they are the same */
  82.       return NULL;
  83.   
  84. !     return NameBuff;
  85.   }
  86.   
  87.   /*
  88. *** ../vim60.183/src/version.c    Mon Feb  4 22:45:19 2002
  89. --- src/version.c    Mon Feb  4 22:45:58 2002
  90. ***************
  91. *** 608,609 ****
  92. --- 608,611 ----
  93.   {   /* Add new patch number below this line */
  94. + /**/
  95. +     184,
  96.   /**/
  97.  
  98. -- 
  99. hundred-and-one symptoms of being an internet addict:
  100. 211. Your husband leaves you...taking the computer with him and you
  101.      call him crying, and beg him to bring the computer back.
  102.  
  103.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  104. (((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
  105.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  106.