mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
fix(coverity): error handling CHECKED_RETURN #31618
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:
parent
738320188f
commit
f9eb68f340
@ -229,10 +229,9 @@ static Object _call_function(String fn, Array args, dict_T *self, Arena *arena,
|
|||||||
funcexe.fe_selfdict = self;
|
funcexe.fe_selfdict = self;
|
||||||
|
|
||||||
TRY_WRAP(err, {
|
TRY_WRAP(err, {
|
||||||
// call_func() retval is deceptive, ignore it. Instead we set `msg_list`
|
// call_func() retval is deceptive, ignore it. Instead TRY_WRAP sets `msg_list` to capture
|
||||||
// (see above) to capture abort-causing non-exception errors.
|
// abort-causing non-exception errors.
|
||||||
call_func(fn.data, (int)fn.size, &rettv, (int)args.size,
|
(void)call_func(fn.data, (int)fn.size, &rettv, (int)args.size, vim_args, &funcexe);
|
||||||
vim_args, &funcexe);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!ERROR_SET(err)) {
|
if (!ERROR_SET(err)) {
|
||||||
@ -280,18 +279,23 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Arena *arena,
|
|||||||
typval_T rettv;
|
typval_T rettv;
|
||||||
bool mustfree = false;
|
bool mustfree = false;
|
||||||
switch (dict.type) {
|
switch (dict.type) {
|
||||||
case kObjectTypeString:
|
case kObjectTypeString: {
|
||||||
|
int eval_ret;
|
||||||
TRY_WRAP(err, {
|
TRY_WRAP(err, {
|
||||||
eval0(dict.data.string.data, &rettv, NULL, &EVALARG_EVALUATE);
|
eval_ret = eval0(dict.data.string.data, &rettv, NULL, &EVALARG_EVALUATE);
|
||||||
clear_evalarg(&EVALARG_EVALUATE, NULL);
|
clear_evalarg(&EVALARG_EVALUATE, NULL);
|
||||||
});
|
});
|
||||||
if (ERROR_SET(err)) {
|
if (ERROR_SET(err)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
if (eval_ret != OK) {
|
||||||
|
abort(); // Should not happen.
|
||||||
|
}
|
||||||
// Evaluation of the string arg created a new dict or increased the
|
// Evaluation of the string arg created a new dict or increased the
|
||||||
// refcount of a dict. Not necessary for a RPC dict.
|
// refcount of a dict. Not necessary for a RPC dict.
|
||||||
mustfree = true;
|
mustfree = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case kObjectTypeDict:
|
case kObjectTypeDict:
|
||||||
object_to_vim(dict, &rettv, err);
|
object_to_vim(dict, &rettv, err);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user