mirror of
https://github.com/moparisthebest/curl
synced 2025-01-05 19:08:06 -05:00
*TERRIBLE* terrible memory leak occuring on all systems that have no
gethostbyname_r() function, most notably windows machines...
This commit is contained in:
parent
be47d83555
commit
8950a2dfa1
@ -125,6 +125,8 @@ struct hostent *Curl_gethost(struct SessionHandle *data,
|
|||||||
{
|
{
|
||||||
struct hostent *h = NULL;
|
struct hostent *h = NULL;
|
||||||
unsigned long in;
|
unsigned long in;
|
||||||
|
|
||||||
|
#ifdef HAVE_GETHOSTBYNAME_R
|
||||||
int ret; /* this variable is unused on several platforms but used on some */
|
int ret; /* this variable is unused on several platforms but used on some */
|
||||||
|
|
||||||
#define CURL_NAMELOOKUP_SIZE 9000
|
#define CURL_NAMELOOKUP_SIZE 9000
|
||||||
@ -136,7 +138,7 @@ struct hostent *Curl_gethost(struct SessionHandle *data,
|
|||||||
if(!buf)
|
if(!buf)
|
||||||
return NULL; /* major failure */
|
return NULL; /* major failure */
|
||||||
*bufp = buf;
|
*bufp = buf;
|
||||||
|
#endif
|
||||||
ret = 0; /* to prevent the compiler warning */
|
ret = 0; /* to prevent the compiler warning */
|
||||||
|
|
||||||
if ( (in=inet_addr(hostname)) != INADDR_NONE ) {
|
if ( (in=inet_addr(hostname)) != INADDR_NONE ) {
|
||||||
@ -206,10 +208,9 @@ struct hostent *Curl_gethost(struct SessionHandle *data,
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
else {
|
else {
|
||||||
|
*bufp=NULL; /* zero this always */
|
||||||
if ((h = gethostbyname(hostname)) == NULL ) {
|
if ((h = gethostbyname(hostname)) == NULL ) {
|
||||||
infof(data, "gethostbyname(2) failed for %s\n", hostname);
|
infof(data, "gethostbyname(2) failed for %s\n", hostname);
|
||||||
free(buf);
|
|
||||||
*bufp=NULL;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user