patch 8.2.5089: some functions return a different value on failure

Problem:    Some functions return a different value on failure.
Solution:   Initialize the return value earlier. (Yegappan Lakshmanan,
            closes #10568)
This commit is contained in:
Yegappan Lakshmanan
2022-06-14 13:42:26 +01:00
committed by Bram Moolenaar
parent cd7496382e
commit ca195cc84f
5 changed files with 14 additions and 6 deletions

View File

@ -1457,6 +1457,9 @@ dict_list(typval_T *argvars, typval_T *rettv, int what)
dict_T *d;
int todo;
if (rettv_list_alloc(rettv) == FAIL)
return;
if (in_vim9script() && check_for_dict_arg(argvars, 0) == FAIL)
return;
@ -1466,8 +1469,6 @@ dict_list(typval_T *argvars, typval_T *rettv, int what)
return;
}
if (rettv_list_alloc(rettv) == FAIL)
return;
if ((d = argvars[0].vval.v_dict) == NULL)
// empty dict behaves like an empty dict
return;