aboutsummaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-10-22 15:05:35 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-10-22 15:05:35 +0000
commit5b358603bd8897dcd38795c1ae971a8f917e97df (patch)
tree2832440bbb6bfa0e7d597707ec02e8e80d73d794 /lib/url.c
parent3910a61b617ed3f943f1f2bc25b3f034a82f692d (diff)
Michal Marek forwarded the bug report
https://bugzilla.novell.com/show_bug.cgi?id=332917 about a HTTP redirect to FTP that caused memory havoc. His work together with my efforts created two fixes: #1 - FTP::file was moved to struct ftp_conn, because is has to be dealt with at connection cleanup, at which time the struct HandleData could be used by another connection. Also, the unused char *urlpath member is removed from struct FTP. #2 - provide a Curl_reset_reqproto() function that frees data->reqdata.proto.* on connection setup if needed (that is if the SessionHandle was used by a different connection).
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/url.c b/lib/url.c
index 212e184f7..1fc11f1c7 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2058,6 +2058,9 @@ static void conn_free(struct connectdata *conn)
if(CURL_SOCKET_BAD != conn->sock[FIRSTSOCKET])
sclose(conn->sock[FIRSTSOCKET]);
+ if (conn->data->reqdata.current_conn == conn) {
+ conn->data->reqdata.current_conn = NULL;
+ }
Curl_safefree(conn->user);
Curl_safefree(conn->passwd);
Curl_safefree(conn->proxyuser);
@@ -4514,3 +4517,16 @@ CURLcode Curl_do_more(struct connectdata *conn)
return result;
}
+
+/* Called on connect, and if there's already a protocol-specific struct
+ allocated for a different connection, this frees it that it can be setup
+ properly later on. */
+void Curl_reset_reqproto(struct connectdata *conn)
+{
+ struct SessionHandle *data = conn->data;
+ if (data->reqdata.proto.generic && data->reqdata.current_conn != conn) {
+ free(data->reqdata.proto.generic);
+ data->reqdata.proto.generic = NULL;
+ }
+ data->reqdata.current_conn = conn;
+}