Skip to content

Commit 4a01159

Browse files
committed
patch 8.2.3291: Coverity warns for not checking return value
Problem: Coverity warns for not checking return value. Solution: If dict_add() fails give an error message.
1 parent 9fe17d4 commit 4a01159

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/if_lua.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,8 @@ luaV_setvar(lua_State *L)
18621862
return 0;
18631863
// Update the value
18641864
copy_tv(&tv, &di->di_tv);
1865-
dict_add(dict, di);
1865+
if (dict_add(dict, di) == FAIL)
1866+
return luaL_error(L, "Couldn't add to dictionary");
18661867
} else
18671868
{
18681869
// Clear the old value

src/testdir/test_lua.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,10 @@ func Test_lua_global_var_table()
10091009
call assert_fails('lua vim.g.Var2[3] = 21', 'list is locked')
10101010
unlockvar g:Var2
10111011

1012+
let g:TestFunc = function('len')
1013+
call assert_fails('lua vim.g.func = vim.g.TestFunc', ['E704:', 'Couldn''t add to dictionary'])
1014+
unlet g:TestFunc
1015+
10121016
" Attempt to access a non-existing global variable
10131017
call assert_equal(v:null, luaeval('vim.g.NonExistingVar'))
10141018
lua vim.g.NonExisting = Nil

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3291,
758760
/**/
759761
3290,
760762
/**/

0 commit comments

Comments
 (0)