]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-var-expand: Fix memory leak if filter fails
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 13 Feb 2025 07:34:23 +0000 (09:34 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 13 Feb 2025 13:02:43 +0000 (15:02 +0200)
Broken in a9d9eb4297a2cccec0cf698a45efb4f1987bdc63

src/lib-var-expand/expansion-statement.c

index 9d2f4d97b0b731e0622d815be021e189e4d8195a..93d4164d9e6bea3ff5816f526496799f911762a7 100644 (file)
@@ -38,6 +38,7 @@ bool var_expand_execute_stmt(struct var_expand_state *state,
                T_BEGIN {
                        ret = (*fn)(stmt, state, &error);
                } T_END_PASS_STR_IF(ret < 0, &error);
+               i_free(delayed_error);
                /* this is to allow e.g. defaut to work correctly */
                if (ret < 0) {
                        var_expand_state_unset_transfer(state);
@@ -45,11 +46,8 @@ bool var_expand_execute_stmt(struct var_expand_state *state,
                                *error_r = t_strdup(state->delayed_error);
                                return FALSE;
                        }
-                       i_free(delayed_error);
                        delayed_error =
                                i_strdup_printf("%s: %s", stmt->function, error);
-               } else {
-                       i_free(delayed_error);
                }
                /* this was already handled in the first branch, so just ignore
                   the error here */