curl-users
Re: --interface dumps core
Date: Sun, 8 Oct 2000 14:54:38 +0200 (MET DST)
On Fri, 6 Oct 2000, Georg Horn wrote:
> as the subject says, curl-7.3 dumps core when i use the --interface
> option. As a quick fix, i removed line 1325 in file url.c:
>
> free(hostdataptr); /* allocated by GetHost() */
>
> GetHost() somewehre calls gethostbyname() and returns the pointer it gets
> from there.
You're right. However, the GetHost() function returns allocated data in all
systems that use gethostbyname_r(). Simply removing that free() will cause a
memory leak for them.
When I investigated this problem a bit further, I've tracked the problem to
be somewhat different. The third argument to the GetHost() function is never
filled in appropriately in the function, why the free() is likely to free()
some random data and thus core.
If the data happened to become NULL, the free() will survive but you'll
instead experience a memory leak. It might be the one you report in your
other mail!
Try this patch instead of removing the free(). It should be a better fix:
diff -u -r1.14 hostip.c
--- hostip.c 2000/09/29 06:34:50 1.14
+++ hostip.c 2000/10/08 12:48:57
@@ -117,6 +117,7 @@
char *buf = (char *)malloc(CURL_NAMELOOKUP_SIZE);
if(!buf)
return NULL; /* major failure */
+ *bufp = buf;
if ( (in=inet_addr(hostname)) != INADDR_NONE ) {
struct in_addr *addrentry;
-- Daniel Stenberg -- curl project maintainer -- http://curl.haxx.se/Received on 2000-10-08