aboutsummaryrefslogtreecommitdiff
path: root/lib/hostip4.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-06-29 18:44:59 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-06-29 18:44:59 +0000
commit7a52f44bd40a440a2ef105933f168dc943cc50c5 (patch)
tree95597ec8625837565f70864d1d3228f77b6bbc94 /lib/hostip4.c
parentefa5485744509f4b20c5ecd2fdc9733f4275cebe (diff)
Gisle fixed a bad free from the resolve reorg, I changed type of the buf
variable to sort out some compiler warnings.
Diffstat (limited to 'lib/hostip4.c')
-rw-r--r--lib/hostip4.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/hostip4.c b/lib/hostip4.c
index 76f75181e..f380d3ef8 100644
--- a/lib/hostip4.c
+++ b/lib/hostip4.c
@@ -196,6 +196,8 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
struct hostent *h = NULL;
in_addr_t in;
struct SessionHandle *data = conn->data;
+ struct hostent *buf = NULL;
+
(void)port; /* unused in IPv4 code */
*waitp = 0; /* don't wait, we act synchronously */
@@ -215,7 +217,8 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
else {
int h_errnop;
int res=ERANGE;
- int *buf = (int *)calloc(CURL_HOSTENT_SIZE, 1);
+
+ buf = (struct hostent *)calloc(CURL_HOSTENT_SIZE, 1);
if(!buf)
return NULL; /* major failure */
/*
@@ -326,7 +329,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
if(!res) { /* success */
- h = (struct hostent*)buf; /* result expected in h */
+ h = buf; /* result expected in h */
/* This is the worst kind of the different gethostbyname_r() interfaces.
* Since we don't know how big buffer this particular lookup required,
@@ -359,7 +362,8 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
if(h) {
ai = Curl_he2ai(h, port);
- free(h);
+ if (h == buf) /* used a *_r() function */
+ free(h);
}
return ai;