]> sjero.net Git - wget/commitdiff
Fix some memory leaks.
authorXin Zou <zouxin2008@gmail.com>
Fri, 12 Jun 2009 02:16:51 +0000 (19:16 -0700)
committerXin Zou <zouxin2008@gmail.com>
Fri, 12 Jun 2009 02:16:51 +0000 (19:16 -0700)
src/ChangeLog
src/http.c

index 6b9ba32d77e4956e68f03b25ecab3461f1f34b59..464e8a916d081fe664576c2d6654e7e7606084b2 100644 (file)
@@ -1,3 +1,7 @@
+2009-06-11  Xin Zou  <zouxin2008@gmail.com>    
+       
+       * http.c (gethttp): Fix some memory leaks.
+       
 2009-06-11  Micah Cowan  <micah@cowan.name>
 
        * http.c (http_atotm): Handle potential for setlocale's return
index 27234198779b7a0b1a44adb99182841bb7c493f6..50f0c6439c776e50a4a75c25f8beb47de4cfcfc5 100644 (file)
@@ -1885,6 +1885,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
                   register_basic_auth_host (u->host);
                 }
               xfree (pth);
+              xfree_null (message);
+              resp_free (resp);
+              xfree (head);
               goto retry_with_auth;
             }
           else
@@ -1895,6 +1898,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
         }
       logputs (LOG_NOTQUIET, _("Authorization failed.\n"));
       request_free (req);
+      xfree_null (message);
+      resp_free (resp);
+      xfree (head);
       return AUTHFAILED;
     }
   else /* statcode != HTTP_STATUS_UNAUTHORIZED */
@@ -1938,6 +1944,8 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
           if (has_html_suffix_p (hs->local_file))
             *dt |= TEXTHTML;
 
+          xfree (head);
+          xfree_null (message);
           return RETRUNNEEDED;
         }
       else if (!ALLOW_CLOBBER)
@@ -2116,6 +2124,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
           else
             CLOSE_INVALIDATE (sock);
           xfree_null (type);
+          xfree (head);
           return NEWLOCATION;
         }
     }
@@ -2171,6 +2180,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
       xfree_null (type);
       CLOSE_INVALIDATE (sock);        /* would be CLOSE_FINISH, but there
                                    might be more bytes in the body. */
+      xfree (head);
       return RETRUNNEEDED;
     }
   if ((contrange != 0 && contrange != hs->restval)
@@ -2180,6 +2190,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
          Bail out.  */
       xfree_null (type);
       CLOSE_INVALIDATE (sock);
+      xfree (head);
       return RANGEERR;
     }
   if (contlen == -1)
@@ -2243,6 +2254,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
         CLOSE_FINISH (sock);
       else
         CLOSE_INVALIDATE (sock);
+      xfree (head);
       return RETRFINISHED;
     }
 
@@ -2269,6 +2281,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
                          _("%s has sprung into existence.\n"),
                          hs->local_file);
               CLOSE_INVALIDATE (sock);
+              xfree (head);
               return FOPEN_EXCL_ERR;
             }
         }
@@ -2276,6 +2289,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
         {
           logprintf (LOG_NOTQUIET, "%s: %s\n", hs->local_file, strerror (errno));
           CLOSE_INVALIDATE (sock);
+          xfree (head);
           return FOPENERR;
         }
     }
@@ -2347,6 +2361,7 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
   struct http_stat hstat;        /* HTTP status */
   struct_stat st;  
   bool send_head_first = true;
+  char *file_name;
 
   /* Assert that no value for *LOCAL_FILE was passed. */
   assert (local_file == NULL || *local_file == NULL);
@@ -2419,10 +2434,12 @@ File %s already there; not retrieving.\n\n"),
 
   /* Send preliminary HEAD request if -N is given and we have an existing 
    * destination file. */
+  file_name = url_file_name (u);
   if (opt.timestamping 
       && !opt.content_disposition
-      && file_exists_p (url_file_name (u)))
+      && file_exists_p (file_name))
     send_head_first = true;
+  xfree (file_name);
   
   /* THE loop */
   do