From aef4b5add55f4bf8b3bf5b050a29e054ba470336 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Thu, 5 Aug 1999 12:23:07 +0000 Subject: [PATCH] (krb5_sname_to_principal): remember to call freehostent git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6757 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/principal.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/krb5/principal.c b/lib/krb5/principal.c index 19401a755..e86b6609f 100644 --- a/lib/krb5/principal.c +++ b/lib/krb5/principal.c @@ -841,7 +841,8 @@ krb5_sname_to_principal (krb5_context context, krb5_error_code ret; char localhost[128]; char **realms, *host = NULL; - + struct hostent *hp = NULL; + if(type != KRB5_NT_SRV_HST && type != KRB5_NT_UNKNOWN) return KRB5_SNAME_UNSUPP_NAMETYPE; if(hostname == NULL){ @@ -850,8 +851,7 @@ krb5_sname_to_principal (krb5_context context, } if(sname == NULL) sname = "host"; - if(type == KRB5_NT_SRV_HST){ - struct hostent *hp = NULL; + if(type == KRB5_NT_SRV_HST) { int error; #ifdef HAVE_IPV6 @@ -866,18 +866,25 @@ krb5_sname_to_principal (krb5_context context, if(type == KRB5_NT_SRV_HST) { host = strdup(hostname); if(host == NULL){ + if (hp != NULL) + freehostent (hp); return ENOMEM; } strlwr(host); hostname = host; } ret = krb5_get_host_realm(context, hostname, &realms); - if(ret) + if(ret) { + if (hp != NULL) + freehostent (hp); return ret; + } ret = krb5_make_principal(context, ret_princ, realms[0], sname, hostname, NULL); if(host) free(host); + if (hp) + freehostent (hp); krb5_free_host_realm(context, realms); return ret; }