curl-library
RE: POST and persistant connections
Date: Sun, 22 Apr 2001 18:06:26 +0200 (MET DST)
On Fri, 20 Apr 2001, Eric Rautman wrote:
> just to follow up my previous post, tracing into url.c, line 1983, I
> found a free() that deallocates the previous conn, causing the pointer to
> the hostname to get hosed.
Yes! Gee, that was silly indeed. The code acts as if the name is alloced
separately, when not.
> Commenting this free() out removes the problem I mentioned before, but
> introducing a memory leak is probably not the best solution.
As a short-term fix, it might do.
> Since I have little time to research a better solution, I mention this
> here in the hope that Daniel or someone with more experience with libcurl
> might have time for a better fix.
>
> Comments (and a fix?) appreciated,
Comment: very good report and problem tracked-down!
Fix (and please let me know how it works):
diff -u -r1.115 url.c
--- url.c 2001/04/18 07:25:11 1.115
+++ url.c 2001/04/22 16:04:01
@@ -2022,8 +2022,9 @@
free(conn->path); /* free the previous path pointer */
/* we need these pointers if we speak over a proxy */
- conn->name = old_conn->name;
- conn->hostname = old_conn->hostname;
+ strcpy(conn->gname, old_conn->gname); /* copy the name */
+ conn->name = conn->gname;
+ conn->hostname = old_conn->gname;
conn->path = path; /* use this one */
conn->ppath = path; /* set this too */
-- Daniel Stenberg -- curl project maintainer -- http://curl.haxx.se/ _______________________________________________ Curl-library mailing list Curl-library_at_lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/curl-libraryReceived on 2001-04-22