From ea490183308631148b5d306ea85e8f80a9d64ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Fri, 20 May 2005 09:07:18 +0000 Subject: [PATCH] (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 --- lib/krb5/krbhst.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/krb5/krbhst.c b/lib/krb5/krbhst.c index 0d7b55066..66aa4cfcc 100644 --- a/lib/krb5/krbhst.c +++ b/lib/krb5/krbhst.c @@ -66,6 +66,9 @@ srv_find_realm(krb5_context context, krb5_krbhst_info ***res, int *count, int proto_num; int def_port; + *res = NULL; + *count = 0; + proto_num = string_to_proto(proto); if(proto_num < 0) { 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); r = dns_lookup(domain, dns_type); - if(r == NULL) { - *res = NULL; - *count = 0; + if(r == NULL) return KRB5_KDC_UNREACH; - } for(num_srv = 0, rr = r->head; rr; rr = rr->next) 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) free((*res)[num_srv]); free(*res); + *res = NULL; return ENOMEM; } (*res)[num_srv++] = hi;