To: vim_dev@googlegroups.com Subject: Patch 8.2.3294 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3294 Problem: Lua: memory leak when adding dict item fails. Solution: Free the typval and the dict item. Files: src/if_lua.c *** ../vim-8.2.3293/src/if_lua.c 2021-08-05 15:11:04.577422906 +0200 --- src/if_lua.c 2021-08-05 16:45:35.675395624 +0200 *************** *** 1859,1870 **** // Need to create an entry di = dictitem_alloc((char_u *)name); if (di == NULL) return 0; // Update the value copy_tv(&tv, &di->di_tv); if (dict_add(dict, di) == FAIL) return luaL_error(L, "Couldn't add to dictionary"); ! } else { // Clear the old value clear_tv(&di->di_tv); --- 1859,1878 ---- // Need to create an entry di = dictitem_alloc((char_u *)name); if (di == NULL) + { + clear_tv(&tv); return 0; + } // Update the value copy_tv(&tv, &di->di_tv); if (dict_add(dict, di) == FAIL) + { + dictitem_free(di); + clear_tv(&tv); return luaL_error(L, "Couldn't add to dictionary"); ! } ! } ! else { // Clear the old value clear_tv(&di->di_tv); *** ../vim-8.2.3293/src/version.c 2021-08-05 16:23:05.482890089 +0200 --- src/version.c 2021-08-05 16:46:34.131267934 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3294, /**/ -- MORTICIAN: Bring out your dead! [clang] Bring out your dead! [clang] Bring out your dead! CUSTOMER: Here's one -- nine pence. DEAD PERSON: I'm not dead! The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///