fix(coverity): error handling (CHECKED_RETURN)

CID 516406:  Error handling issues  (CHECKED_RETURN)
    /src/nvim/api/vimscript.c: 284 in nvim_call_dict_function()
    278       Object rv = OBJECT_INIT;
    279
    280       typval_T rettv;
    281       bool mustfree = false;
    282       switch (dict.type) {
    283       case kObjectTypeString:
    >>>     CID 516406:  Error handling issues  (CHECKED_RETURN)
    >>>     Calling "eval0" without checking return value (as is done elsewhere 10 out of 12 times).
    284         TRY_WRAP(err, {
    285           eval0(dict.data.string.data, &rettv, NULL, &EVALARG_EVALUATE);
    286           clear_evalarg(&EVALARG_EVALUATE, NULL);
    287         });
    288         if (ERROR_SET(err)) {
    289           return rv;
This commit is contained in:
Justin M. Keyes 2024-12-18 01:52:02 +01:00
parent 51c380238c
commit 0d08aeccad

View File

@ -282,7 +282,10 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Arena *arena,
switch (dict.type) {
case kObjectTypeString:
TRY_WRAP(err, {
eval0(dict.data.string.data, &rettv, NULL, &EVALARG_EVALUATE);
int rv = eval0(dict.data.string.data, &rettv, NULL, &EVALARG_EVALUATE);
if (rv != OK && !ERROR_SET(err)) {
abort();
}
clear_evalarg(&EVALARG_EVALUATE, NULL);
});
if (ERROR_SET(err)) {