From: Aki Tuomi Date: Thu, 13 Feb 2025 07:34:23 +0000 (+0200) Subject: lib-var-expand: Fix memory leak if filter fails X-Git-Tag: 2.4.1~206 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afa250713e3e77cf077c48ea4145dff73001ae04;p=thirdparty%2Fdovecot%2Fcore.git lib-var-expand: Fix memory leak if filter fails Broken in a9d9eb4297a2cccec0cf698a45efb4f1987bdc63 --- diff --git a/src/lib-var-expand/expansion-statement.c b/src/lib-var-expand/expansion-statement.c index 9d2f4d97b0..93d4164d9e 100644 --- a/src/lib-var-expand/expansion-statement.c +++ b/src/lib-var-expand/expansion-statement.c @@ -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 */