diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c index 46b41fd2cee..91e02f9d94d 100644 --- a/source4/dsdb/samdb/cracknames.c +++ b/source4/dsdb/samdb/cracknames.c @@ -307,11 +307,14 @@ static WERROR DsCrackNameUPN(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, realm = smb_krb5_principal_get_realm( mem_ctx, smb_krb5_context->krb5_context, principal); if (realm == NULL) { + krb5_free_principal(smb_krb5_context->krb5_context, principal); return WERR_NOT_ENOUGH_MEMORY; } realm_encoded = ldb_binary_encode_string(mem_ctx, realm); if (realm_encoded == NULL) { + TALLOC_FREE(realm); + krb5_free_principal(smb_krb5_context->krb5_context, principal); return WERR_NOT_ENOUGH_MEMORY; }