]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Fix %{ldap_dn} not to leak memory
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 19 Oct 2017 12:39:28 +0000 (15:39 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 19 Oct 2017 12:44:23 +0000 (15:44 +0300)
src/auth/db-ldap.c

index c03fecaf4b00256f0ac2e264f63d641c51545ab4..734fa81410c522556ee2d68f9db8497b68326ce2 100644 (file)
@@ -1679,7 +1679,9 @@ db_ldap_field_dn_expand(const char *data ATTR_UNUSED, void *context ATTR_UNUSED,
                         const char **value_r, const char **error_r ATTR_UNUSED)
 {
        struct db_ldap_result_iterate_context *ctx = context;
-       *value_r = ldap_get_dn(ctx->ld, ctx->ldap_msg);
+       char *dn = ldap_get_dn(ctx->ld, ctx->ldap_msg);
+       *value_r = t_strdup(dn);
+       ldap_memfree(dn);
        return 1;
 }