]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
var-expand: Delegate error-handling in var_expand_try_extension()
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Tue, 5 Jul 2022 11:26:38 +0000 (13:26 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 7 Jul 2022 13:49:27 +0000 (13:49 +0000)
src/lib/var-expand.c

index 8ec68fd7c920e72c9138b97c958821f1cf37e61b..6245c1266ae2b5c344cd8009c9961cf09ec8e987 100644 (file)
@@ -380,6 +380,8 @@ var_expand_func(const struct var_expand_func_table *func_table,
                for (; func_table->key != NULL; func_table++) {
                        if (strcmp(func_table->key, key) == 0) {
                                ret = func_table->func(data, context, &value, error_r);
+                               if (*error_r == NULL)
+                                       *error_r = t_strdup_printf("Unknown variables in function %%%s", key);
                                *var_r = value != NULL ? value : "";
                                return ret;
                        }
@@ -412,12 +414,8 @@ var_expand_try_extension(struct var_expand_context *ctx,
                        return ret;
                }
        }
-       if ((ret = var_expand_func(ctx->func_table, key, data,
-                                  ctx->context, var_r, error_r)) == 0) {
-               if (*error_r == NULL)
-                       *error_r = t_strdup_printf("Unknown variables in function %%%s", key);
-       }
-       return ret;
+       return var_expand_func(ctx->func_table, key, data,
+                              ctx->context, var_r, error_r);
 }