From 14d0c5f34afdf2f9e38340d536741baa3dd55e5f Mon Sep 17 00:00:00 2001 From: Andrew Munger Date: Tue, 19 Sep 2006 04:25:14 +0000 Subject: [PATCH] Initialize h_alises with a length 1 array containing a terminating null as specified. Patch by arty. (Fixes ncftp connection) svn path=/trunk/; revision=24209 --- reactos/dll/win32/ws2_32/misc/ns.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/reactos/dll/win32/ws2_32/misc/ns.c b/reactos/dll/win32/ws2_32/misc/ns.c index 9e166e65ef8..f6103b09c14 100644 --- a/reactos/dll/win32/ws2_32/misc/ns.c +++ b/reactos/dll/win32/ws2_32/misc/ns.c @@ -488,7 +488,10 @@ void populate_hostent(struct hostent *he, char* name, DNS_A_DATA addr) name, MAX_HOSTNAME_LEN); - he->h_aliases = 0; + if( !he->h_aliases ) { + he->h_aliases = HeapAlloc(GlobalHeap, 0, sizeof(char *)); + he->h_aliases[0] = 0; + } he->h_addrtype = AF_INET; he->h_length = sizeof(IN_ADDR); //sizeof(struct in_addr); @@ -518,12 +521,20 @@ void free_hostent(struct hostent *he) { if(he) { + char *next = 0; HFREE(he->h_name); - char *next = he->h_aliases[0]; - while(next) { HFREE(next); next++; } - next = he->h_addr_list[0]; - while(next) { HFREE(next); next++; } + if(he->h_aliases) + { + next = he->h_aliases[0]; + while(next) { HFREE(next); next++; } + } + if(he->h_addr_list) + { + next = he->h_addr_list[0]; + while(next) { HFREE(next); next++; } + } HFREE(he->h_addr_list); + HFREE(he->h_aliases); HFREE(he); } }