]> granicus.if.org Git - vim/commitdiff
patch 8.2.3291: Coverity warns for not checking return value v8.2.3291
authorBram Moolenaar <Bram@vim.org>
Thu, 5 Aug 2021 13:11:08 +0000 (15:11 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 5 Aug 2021 13:11:08 +0000 (15:11 +0200)
Problem:    Coverity warns for not checking return value.
Solution:   If dict_add() fails give an error message.

src/if_lua.c
src/testdir/test_lua.vim
src/version.c

index bcd0b02f97aac3e3bae48a64cb37f34bfde1b5d1..144fcbea5f9ed5863a1776ec0ac7ee22e0356abc 100644 (file)
@@ -1862,7 +1862,8 @@ luaV_setvar(lua_State *L)
                return 0;
            // Update the value
            copy_tv(&tv, &di->di_tv);
-           dict_add(dict, di);
+           if (dict_add(dict, di) == FAIL)
+               return luaL_error(L, "Couldn't add to dictionary");
        } else
        {
            // Clear the old value
index 953e8a9b677afdb3b36fea4743cfec8f7040fa57..94e3ceccc031d7cf950c477d1b98f9c8dec151e6 100644 (file)
@@ -1009,6 +1009,10 @@ func Test_lua_global_var_table()
   call assert_fails('lua vim.g.Var2[3] = 21', 'list is locked')
   unlockvar g:Var2
 
+  let g:TestFunc = function('len')
+  call assert_fails('lua vim.g.func = vim.g.TestFunc', ['E704:', 'Couldn''t add to dictionary'])
+  unlet g:TestFunc
+
   " Attempt to access a non-existing global variable
   call assert_equal(v:null, luaeval('vim.g.NonExistingVar'))
   lua vim.g.NonExisting = Nil
index 905bc4eec0970024649459765ed9db39d2656092..b88b7503ac46fc138f6601127b2c7e09ee42c0f0 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3291,
 /**/
     3290,
 /**/