]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5089: some functions return a different value on failure v8.2.5089
authorYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 14 Jun 2022 12:42:26 +0000 (13:42 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 14 Jun 2022 12:42:26 +0000 (13:42 +0100)
Problem:    Some functions return a different value on failure.
Solution:   Initialize the return value earlier. (Yegappan Lakshmanan,
            closes #10568)

src/autocmd.c
src/dict.c
src/evalfunc.c
src/list.c
src/version.c

index 71aeb5036bf8926f5147bd1b83969982a259f48d..841da146226c071b6eb0bb51176595ed0a1ff00e 100644 (file)
@@ -3062,6 +3062,8 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
     char_u     *name = NULL;
     int                group = AUGROUP_ALL;
 
+    if (rettv_list_alloc(rettv) == FAIL)
+       return;
     if (check_for_opt_dict_arg(argvars, 0) == FAIL)
        return;
 
@@ -3128,8 +3130,6 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
        }
     }
 
-    if (rettv_list_alloc(rettv) == FAIL)
-       return;
     event_list = rettv->vval.v_list;
 
     // iterate through all the autocmd events
index 538dd8ba264911719a547fdb2596306e8787cdaf..d2819578a7d35fc45b841f754d9b415d74d7a299 100644 (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;
index ff30756dda7d1594c3f379078fd34bae028f87d5..d85e85460c08fbd7fa635d3cc4b4d72357e8e207 100644 (file)
@@ -8133,6 +8133,9 @@ f_range(typval_T *argvars, typval_T *rettv)
     varnumber_T        stride = 1;
     int                error = FALSE;
 
+    if (rettv_list_alloc(rettv) != OK)
+       return;
+
     if (in_vim9script()
            && (check_for_number_arg(argvars, 0) == FAIL
                || check_for_opt_number_arg(argvars, 1) == FAIL
@@ -8159,7 +8162,7 @@ f_range(typval_T *argvars, typval_T *rettv)
        emsg(_(e_stride_is_zero));
     else if (stride > 0 ? end + 1 < start : end - 1 > start)
        emsg(_(e_start_past_end));
-    else if (rettv_list_alloc(rettv) == OK)
+    else
     {
        list_T *list = rettv->vval.v_list;
 
index 50bf3afc0f524bdfeb6a087b3760fca12959447a..b9a347836bd0a2e5021d87e27f06b6bfa377dbd2 100644 (file)
@@ -1440,6 +1440,8 @@ f_join(typval_T *argvars, typval_T *rettv)
     garray_T   ga;
     char_u     *sep;
 
+    rettv->v_type = VAR_STRING;
+
     if (in_vim9script()
            && (check_for_list_arg(argvars, 0) == FAIL
                || check_for_opt_string_arg(argvars, 1) == FAIL))
@@ -1450,7 +1452,7 @@ f_join(typval_T *argvars, typval_T *rettv)
        emsg(_(e_list_required));
        return;
     }
-    rettv->v_type = VAR_STRING;
+
     if (argvars[0].vval.v_list == NULL)
        return;
 
index 02600f7559447a863f2a8b01bbec331e2e652081..aa1319c690773faa302df91e942ae16ad606d635 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5089,
 /**/
     5088,
 /**/