To: vim_dev@googlegroups.com Subject: Patch 8.2.0399 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0399 Problem: Various memory leaks. Solution: Avoid the leaks. (Ozaki Kiichi, closes #5803) Files: src/ex_docmd.c, src/ex_getln.c, src/menu.c, src/message.c, src/scriptfile.c, src/userfunc.c *** ../vim-8.2.0398/src/ex_docmd.c 2020-03-09 16:40:36.246782095 +0100 --- src/ex_docmd.c 2020-03-18 13:58:54.515544310 +0100 *************** *** 1346,1351 **** --- 1346,1363 ---- restore_dbg_stuff(&debug_saved); msg_list = saved_msg_list; + + // Cleanup if "cs_emsg_silent_list" remains. + if (cstack.cs_emsg_silent_list != NULL) + { + eslist_T *elem, *temp; + + for (elem = cstack.cs_emsg_silent_list; elem != NULL; elem = temp) + { + temp = elem->next; + vim_free(elem); + } + } #endif // FEAT_EVAL /* *** ../vim-8.2.0398/src/ex_getln.c 2020-02-21 21:30:33.867979726 +0100 --- src/ex_getln.c 2020-03-18 13:58:54.515544310 +0100 *************** *** 4188,4193 **** --- 4188,4194 ---- if (win_split((int)p_cwh, WSP_BOT) == FAIL) { beep_flush(); + ga_clear(&winsizes); return K_IGNORE; } cmdwin_type = get_cmdline_type(); *** ../vim-8.2.0398/src/menu.c 2020-03-16 20:04:37.852453460 +0100 --- src/menu.c 2020-03-18 13:58:54.515544310 +0100 *************** *** 2882,2891 **** if (bit < MENU_MODES) // just in case, avoid Coverity warning { if (menu->strings[bit] != NULL) status = dict_add_string(dict, "rhs", *menu->strings[bit] == NUL ! ? vim_strsave((char_u *)"") ! : str2special_save(menu->strings[bit], FALSE)); if (status == OK) status = dict_add_bool(dict, "noremenu", menu->noremap[bit] == REMAP_NONE); --- 2882,2897 ---- if (bit < MENU_MODES) // just in case, avoid Coverity warning { if (menu->strings[bit] != NULL) + { + char_u *tofree = NULL; + status = dict_add_string(dict, "rhs", *menu->strings[bit] == NUL ! ? (char_u *)"" ! : (tofree = str2special_save( ! menu->strings[bit], FALSE))); ! vim_free(tofree); ! } if (status == OK) status = dict_add_bool(dict, "noremenu", menu->noremap[bit] == REMAP_NONE); *** ../vim-8.2.0398/src/message.c 2020-03-08 18:41:03.407429568 +0100 --- src/message.c 2020-03-18 14:00:23.367194395 +0100 *************** *** 865,870 **** --- 865,871 ---- char_u *copy = vim_strnsave((char_u *)name, len); semsg(msg, copy == NULL ? "NULL" : (char *)copy); + vim_free(copy); } /* *** ../vim-8.2.0398/src/scriptfile.c 2020-02-23 18:08:29.463897252 +0100 --- src/scriptfile.c 2020-03-18 13:58:54.519544294 +0100 *************** *** 1133,1139 **** { // Already loaded and no need to load again, return here. *ret_sid = sid; ! return OK; } #endif --- 1133,1140 ---- { // Already loaded and no need to load again, return here. *ret_sid = sid; ! retval = OK; ! goto theend; } #endif *** ../vim-8.2.0398/src/userfunc.c 2020-03-01 23:32:22.348059441 +0100 --- src/userfunc.c 2020-03-18 13:58:54.519544294 +0100 *************** *** 942,947 **** --- 942,949 ---- ga_clear_strings(&(fp->uf_lines)); VIM_CLEAR(fp->uf_name_exp); VIM_CLEAR(fp->uf_arg_types); + VIM_CLEAR(fp->uf_def_arg_idx); + VIM_CLEAR(fp->uf_va_name); ga_clear(&fp->uf_type_list); #ifdef FEAT_PROFILE VIM_CLEAR(fp->uf_tml_count); *************** *** 3086,3096 **** erret: ga_clear_strings(&newargs); - ga_clear_strings(&argtypes); ga_clear_strings(&default_args); errret_2: ga_clear_strings(&newlines); ret_free: vim_free(skip_until); vim_free(line_to_free); vim_free(fudi.fd_newkey); --- 3088,3098 ---- erret: ga_clear_strings(&newargs); ga_clear_strings(&default_args); errret_2: ga_clear_strings(&newlines); ret_free: + ga_clear_strings(&argtypes); vim_free(skip_until); vim_free(line_to_free); vim_free(fudi.fd_newkey); *** ../vim-8.2.0398/src/version.c 2020-03-17 20:57:00.654899725 +0100 --- src/version.c 2020-03-18 15:22:50.315774939 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 399, /**/ -- Facepalm reply #3: "I had a great time in Manhattan" "I thought you were going to New York?" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///