Bug report #1779751 (http://curl.haxx.se/bug/view.cgi?id=1779751) pointed
authorDaniel Stenberg <daniel@haxx.se>
Wed, 22 Aug 2007 22:48:41 +0000 (22:48 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 22 Aug 2007 22:48:41 +0000 (22:48 +0000)
out that doing first a file:// upload and then an FTP upload crashed libcurl
or at best caused furious valgrind complaints. Fixed now by making sure we
free and clear the file-specific struct properly when done with it.

CHANGES
RELEASE-NOTES
lib/file.c

diff --git a/CHANGES b/CHANGES
index 73b73f0..bb963d7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,11 @@
 
                                   Changelog
 
+Daniel S (23 August 2007)
+- Bug report #1779751 (http://curl.haxx.se/bug/view.cgi?id=1779751) pointed
+  out that doing first a file:// upload and then an FTP upload crashed libcurl
+  or at best caused furious valgrind complaints. Fixed now!
+
 Daniel S (22 August 2007)
 - Bug report #1779054 (http://curl.haxx.se/bug/view.cgi?id=1779054) pointed
   out that libcurl didn't deal with very long (>16K) FTP server response lines
index a5e660e..dd61e24 100644 (file)
@@ -45,6 +45,7 @@ This release includes the following bugfixes:
  o FTP NOBODY requests on directories sent "SIZE (null)"
  o FTP NOBODY request on file crash
  o excessively long FTP server response lines
+ o file:// upload then FTP:// upload crash
 
 This release includes the following known bugs:
 
index 8562cc2..1abc838 100644 (file)
@@ -96,7 +96,8 @@
  */
 CURLcode Curl_file_connect(struct connectdata *conn)
 {
-  char *real_path = curl_easy_unescape(conn->data, conn->data->reqdata.path, 0, NULL);
+  char *real_path = curl_easy_unescape(conn->data, conn->data->reqdata.path, 0,
+                                       NULL);
   struct FILEPROTO *file;
   int fd;
 #if defined(WIN32) || defined(MSDOS) || defined(__EMX__)
@@ -113,9 +114,8 @@ CURLcode Curl_file_connect(struct connectdata *conn)
     return CURLE_OUT_OF_MEMORY;
   }
 
-  if (conn->data->reqdata.proto.file) {
+  if (conn->data->reqdata.proto.file)
     free(conn->data->reqdata.proto.file);
-  }
 
   conn->data->reqdata.proto.file = file;
 
@@ -177,6 +177,9 @@ CURLcode Curl_file_done(struct connectdata *conn,
   if(file->fd != -1)
     close(file->fd);
 
+  free(file);
+  conn->data->reqdata.proto.file= NULL; /* clear it! */
+
   return CURLE_OK;
 }