]> sjero.net Git - wget/blobdiff - src/ftp-ls.c
[svn] Fix obvious memory leaks in the VMS directory parser.
[wget] / src / ftp-ls.c
index d7e00ea7bb4a1e9d5d40244824e186bedf0dda8d..bf613b24938d4374aceca650afd9b06c93a0deaf 100644 (file)
@@ -577,19 +577,31 @@ ftp_parse_vms_ls (const char *file)
     }
   dir = l = NULL;
 
-  /* Empty line */
-  read_whole_line (fp);
-  /* "Directory PUB$DEVICE[PUB]" */
-  read_whole_line (fp);
-  /* Empty line */
-  read_whole_line (fp);
+  /* Skip empty line. */
+  line = read_whole_line (fp);
+  if (line)
+    xfree (line);
+
+  /* Skip "Directory PUB$DEVICE[PUB]" */
+  line = read_whole_line (fp);
+  if (line)
+    xfree (line);
+
+  /* Skip empty line. */
+  line = read_whole_line (fp);
+  if (line)
+    xfree (line);
 
   /* Line loop to end of file: */
   while ((line = read_whole_line (fp)))
     {
       char *p;
       i = clean_line (line);
-      if (!i) break;
+      if (!i)
+       {
+         xfree (line);
+         break;
+       }
 
       /* First column: Name. A bit of black magic again. The name my be
          either ABCD.EXT or ABCD.EXT;NUM and it might be on a separate
@@ -646,6 +658,7 @@ ftp_parse_vms_ls (const char *file)
         if (!i) 
         {
           DEBUGP(("confusing VMS listing item, leaving listing parser\n"));
+         xfree (line);
           break;
         }
         tok = strtok(line, " ");
@@ -665,6 +678,7 @@ ftp_parse_vms_ls (const char *file)
            the first strtok(NULL, "-") will return everything until the end
            of the line and only the next strtok() call will return NULL. */
         DEBUGP(("nonsense in VMS listing, skipping this line\n"));
+       xfree (line);
         break;
       }
       for (i=0; i<12; i++) if (!strcmp(tok,months[i])) break;
@@ -714,6 +728,7 @@ ftp_parse_vms_ls (const char *file)
       if (tok == NULL)
         {
           DEBUGP(("confusing VMS permissions, skipping line\n"));
+         xfree (line);
           continue;
         }
       /* Permissons have the format "RWED,RWED,RE" */
@@ -796,7 +811,7 @@ Unsupported listing type, trying Unix listing parser.\n"));
    directories and files on the appropriate host.  The references are
    FTP.  */
 uerr_t
-ftp_index (const char *file, struct urlinfo *u, struct fileinfo *f)
+ftp_index (const char *file, struct url *u, struct fileinfo *f)
 {
   FILE *fp;
   char *upwd;