]> sjero.net Git - wget/commitdiff
Fix some memory leaks.
authorGiuseppe Scrivano <gscrivano@gnu.org>
Fri, 11 Mar 2011 14:25:58 +0000 (15:25 +0100)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Fri, 11 Mar 2011 14:25:58 +0000 (15:25 +0100)
src/ChangeLog
src/ftp-ls.c
src/ftp.c

index 28aa1a5912ad7bbc082a9c5882df9f08244f0c96..44800fe2f0592b42c8cdc02b2d534cbeb08c4419 100644 (file)
@@ -1,3 +1,9 @@
+2011-03-11  Giuseppe Scrivano  <gscrivano@gnu.org>
+
+       * ftp.c (getftp): Fix some memory leaks.
+       * ftp-ls.c (ftp_parse_winnt_ls): Likewise.
+       Reported by: Zhenbo Xu <zhenbo1987@gmail.com>.
+
 2010-11-20  Filipe Brandenburger <filbranden@gmail.com> (tiny change)
 
        * http.c (gethttp): Repeat a POST request on a 307 response.
index 2ff57cc05b2d63c9355a088a100cf81c4d2b0ca7..40c11f3930f51aa6e67ed75dc29c236169880710 100644 (file)
@@ -455,7 +455,7 @@ ftp_parse_winnt_ls (const char *file)
          column 39 of the listing. This way we could also recognize
          filenames that begin with a series of space characters (but who
          really wants to use such filenames anyway?). */
-      if (len < 40) continue;
+      if (len < 40) goto continue_loop;
       tok = line + 39;
       cur.name = xstrdup(tok);
       DEBUGP (("Name: '%s'\n", cur.name));
@@ -463,14 +463,14 @@ ftp_parse_winnt_ls (const char *file)
       /* First column: mm-dd-yy. Should atoi() on the month fail, january
          will be assumed.  */
       tok = strtok(line, "-");
-      if (tok == NULL) continue;
+      if (tok == NULL) goto continue_loop;
       month = atoi(tok) - 1;
       if (month < 0) month = 0;
       tok = strtok(NULL, "-");
-      if (tok == NULL) continue;
+      if (tok == NULL) goto continue_loop;
       day = atoi(tok);
       tok = strtok(NULL, " ");
-      if (tok == NULL) continue;
+      if (tok == NULL) goto continue_loop;
       year = atoi(tok);
       /* Assuming the epoch starting at 1.1.1970 */
       if (year <= 70) year += 100;
@@ -478,10 +478,10 @@ ftp_parse_winnt_ls (const char *file)
       /* Second column: hh:mm[AP]M, listing does not contain value for
          seconds */
       tok = strtok(NULL,  ":");
-      if (tok == NULL) continue;
+      if (tok == NULL) goto continue_loop;
       hour = atoi(tok);
       tok = strtok(NULL,  "M");
-      if (tok == NULL) continue;
+      if (tok == NULL) goto continue_loop;
       min = atoi(tok);
       /* Adjust hour from AM/PM. Just for the record, the sequence goes
          11:00AM, 12:00PM, 01:00PM ... 11:00PM, 12:00AM, 01:00AM . */
@@ -512,9 +512,9 @@ ftp_parse_winnt_ls (const char *file)
          directories as the listing does not give us a clue) and filetype
          here. */
       tok = strtok(NULL, " ");
-      if (tok == NULL) continue;
+      if (tok == NULL) goto continue_loop;
       while ((tok != NULL) && (*tok == '\0'))  tok = strtok(NULL, " ");
-      if (tok == NULL) continue;
+      if (tok == NULL) goto continue_loop;
       if (*tok == '<')
         {
           cur.type  = FT_DIRECTORY;
@@ -554,6 +554,7 @@ ftp_parse_winnt_ls (const char *file)
           l->next = NULL;
         }
 
+continue_loop:
       xfree (line);
     }
 
index 2cc341bd2a09f70f561f6d5b26f0364ffabdc9dc..9e4f3d76bcbc231f4c74402fd00a81c2eed100f9 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -301,10 +301,20 @@ getftp (struct url *u, wgint passed_expected_bytes, wgint *qtyread,
 
       csock = connect_to_host (host, port);
       if (csock == E_HOST)
-        return HOSTERR;
+        {
+          if (con->proxy)
+            xfree (logname);
+
+          return HOSTERR;
+        }
       else if (csock < 0)
-        return (retryable_socket_connect_error (errno)
-                ? CONERROR : CONIMPOSSIBLE);
+        {
+          if (con->proxy)
+            xfree (logname);
+
+          return (retryable_socket_connect_error (errno)
+                  ? CONERROR : CONIMPOSSIBLE);
+        }
 
       if (cmd & LEAVE_PENDING)
         con->csock = csock;