(srv_find_realm): make sure res' and count' have good values

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15200 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-05-20 09:07:18 +00:00
parent 305ca701d3
commit ea49018330

View File

@@ -66,6 +66,9 @@ srv_find_realm(krb5_context context, krb5_krbhst_info ***res, int *count,
int proto_num; int proto_num;
int def_port; int def_port;
*res = NULL;
*count = 0;
proto_num = string_to_proto(proto); proto_num = string_to_proto(proto);
if(proto_num < 0) { if(proto_num < 0) {
krb5_set_error_string(context, "unknown protocol `%s'", proto); krb5_set_error_string(context, "unknown protocol `%s'", proto);
@@ -82,11 +85,8 @@ srv_find_realm(krb5_context context, krb5_krbhst_info ***res, int *count,
snprintf(domain, sizeof(domain), "_%s._%s.%s.", service, proto, realm); snprintf(domain, sizeof(domain), "_%s._%s.%s.", service, proto, realm);
r = dns_lookup(domain, dns_type); r = dns_lookup(domain, dns_type);
if(r == NULL) { if(r == NULL)
*res = NULL;
*count = 0;
return KRB5_KDC_UNREACH; return KRB5_KDC_UNREACH;
}
for(num_srv = 0, rr = r->head; rr; rr = rr->next) for(num_srv = 0, rr = r->head; rr; rr = rr->next)
if(rr->type == T_SRV) if(rr->type == T_SRV)
@@ -112,6 +112,7 @@ srv_find_realm(krb5_context context, krb5_krbhst_info ***res, int *count,
while(--num_srv >= 0) while(--num_srv >= 0)
free((*res)[num_srv]); free((*res)[num_srv]);
free(*res); free(*res);
*res = NULL;
return ENOMEM; return ENOMEM;
} }
(*res)[num_srv++] = hi; (*res)[num_srv++] = hi;