(add_hostent): don't use just-freed memory
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8794 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -246,10 +246,10 @@ add_hostent (int port, int protocol, int socktype,
|
|||||||
char **h;
|
char **h;
|
||||||
|
|
||||||
if (*flags & AI_CANONNAME) {
|
if (*flags & AI_CANONNAME) {
|
||||||
canonname = find_fqdn (he);
|
struct hostent *he2 = NULL;
|
||||||
|
|
||||||
|
canonname = find_fqdn (he);
|
||||||
if (strchr (canonname, '.') == NULL) {
|
if (strchr (canonname, '.') == NULL) {
|
||||||
struct hostent *he2;
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
he2 = getipnodebyaddr (he->h_addr_list[0], he->h_length,
|
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)
|
if (strchr (tmp, '.') != NULL)
|
||||||
canonname = tmp;
|
canonname = tmp;
|
||||||
freehostent (he2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canonname = strdup (canonname);
|
canonname = strdup (canonname);
|
||||||
|
if (he2 != NULL)
|
||||||
|
freehostent (he2);
|
||||||
if (canonname == NULL)
|
if (canonname == NULL)
|
||||||
return EAI_MEMORY;
|
return EAI_MEMORY;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user