To: vim-dev@vim.org Subject: Patch 6.0.184 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.184 Problem: Leaking memory when expanding option values. Solution: Don't always copy the expanded option into allocated memory. Files: src/option.c *** ../vim60.183/src/option.c Wed Jan 30 16:50:08 2002 --- src/option.c Mon Feb 4 22:17:17 2002 *************** *** 3460,3467 **** { s = option_expand(opt_idx, newval); if (s == NULL) ! s = vim_strsave(newval); ! newval = s; } new_value_alloced = TRUE; } --- 3460,3467 ---- { s = option_expand(opt_idx, newval); if (s == NULL) ! s = newval; ! newval = vim_strsave(s); } new_value_alloced = TRUE; } *************** *** 3955,3961 **** * Expand environment variables for some string options. * These string options cannot be indirect! * If "val" is NULL expand the current value of the option. ! * Return pointer to allocated memory, or NULL when not expanded. */ static char_u * option_expand(opt_idx, val) --- 3955,3961 ---- * Expand environment variables for some string options. * These string options cannot be indirect! * If "val" is NULL expand the current value of the option. ! * Return pointer to NameBuff, or NULL when not expanded. */ static char_u * option_expand(opt_idx, val) *************** *** 3967,3973 **** return NULL; /* If val is longer than MAXPATHL no meaningful expansion can be done, ! * expand_env would truncate the string. */ if (val != NULL && STRLEN(val) > MAXPATHL) return NULL; --- 3967,3973 ---- return NULL; /* If val is longer than MAXPATHL no meaningful expansion can be done, ! * expand_env() would truncate the string. */ if (val != NULL && STRLEN(val) > MAXPATHL) return NULL; *************** *** 3981,3987 **** if (STRCMP(NameBuff, val) == 0) /* they are the same */ return NULL; ! return vim_strsave(NameBuff); } /* --- 3981,3987 ---- if (STRCMP(NameBuff, val) == 0) /* they are the same */ return NULL; ! return NameBuff; } /* *** ../vim60.183/src/version.c Mon Feb 4 22:45:19 2002 --- src/version.c Mon Feb 4 22:45:58 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 184, /**/ -- hundred-and-one symptoms of being an internet addict: 211. Your husband leaves you...taking the computer with him and you call him crying, and beg him to bring the computer back. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///