Fix memory leak in name canon rule iterator

This commit is contained in:
Nicolas Williams
2011-10-31 00:15:07 -05:00
parent c8f1a6f0a0
commit 7da9d7d75f

View File

@@ -1870,9 +1870,10 @@ krb5_name_canon_iterator_start(krb5_context context,
state->in_princ = princ; state->in_princ = princ;
if (in_creds) { if (in_creds) {
ret = krb5_copy_creds(context, in_creds, &state->creds); if (!state->is_trivial) {
if (ret) ret = krb5_copy_creds(context, in_creds, &state->creds);
goto out; if (ret) goto err;
}
state->tmp_princ = state->creds->server; /* so we don't leak */ state->tmp_princ = state->creds->server; /* so we don't leak */
} }
@@ -1908,8 +1909,8 @@ krb5_name_canon_iterate(krb5_context context,
return 0; return 0;
} }
krb5_free_principal(context, state->tmp_princ);
do { do {
krb5_free_principal(context, state->tmp_princ);
ret = _krb5_apply_name_canon_rule(context, state->rule, ret = _krb5_apply_name_canon_rule(context, state->rule,
state->in_princ, &state->tmp_princ, rule_opts); state->in_princ, &state->tmp_princ, rule_opts);
if (ret) if (ret)