From 2341a48bda1306797570c5b8176180b5bf5edad8 Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Fri, 2 Dec 2011 18:52:22 +0000 Subject: [PATCH] Fix free ofuninitialized memory in sname_to_princ Fix free of uninitialized memory in error case introduced in 1.10 development cycle. ticket: 7036 tags: pullup Target_Version: 1.10 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25498 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/sn2princ.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/krb5/os/sn2princ.c b/src/lib/krb5/os/sn2princ.c index 8f8a0ce8e..1bee5ae81 100644 --- a/src/lib/krb5/os/sn2princ.c +++ b/src/lib/krb5/os/sn2princ.c @@ -90,7 +90,7 @@ krb5_sname_to_principal(krb5_context context, const char *hostname, const char * /* copy the hostname into non-volatile storage */ if (type == KRB5_NT_SRV_HST) { - struct addrinfo *ai, hints; + struct addrinfo *ai = NULL, hints; int err; char hnamebuf[NI_MAXHOST]; @@ -114,7 +114,8 @@ krb5_sname_to_principal(krb5_context context, const char *hostname, const char * } remote_host = strdup((ai && ai->ai_canonname) ? ai->ai_canonname : hostname); if (!remote_host) { - freeaddrinfo(ai); + if(ai) + freeaddrinfo(ai); return ENOMEM; } -- 2.26.2