From 531d514e9fbf590a4de3dc6bd8512f3efc7fb10f Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Mon, 24 Jul 2000 02:34:20 +0000 Subject: [PATCH] (add_hostent): don't use just-freed memory git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8794 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/roken/getaddrinfo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/roken/getaddrinfo.c b/lib/roken/getaddrinfo.c index 3fae47db5..0a6e5007a 100644 --- a/lib/roken/getaddrinfo.c +++ b/lib/roken/getaddrinfo.c @@ -246,10 +246,10 @@ add_hostent (int port, int protocol, int socktype, char **h; if (*flags & AI_CANONNAME) { - canonname = find_fqdn (he); + struct hostent *he2 = NULL; + canonname = find_fqdn (he); if (strchr (canonname, '.') == NULL) { - struct hostent *he2; int error; he2 = getipnodebyaddr (he->h_addr_list[0], he->h_length, @@ -259,11 +259,12 @@ add_hostent (int port, int protocol, int socktype, if (strchr (tmp, '.') != NULL) canonname = tmp; - freehostent (he2); } } canonname = strdup (canonname); + if (he2 != NULL) + freehostent (he2); if (canonname == NULL) return EAI_MEMORY; }