]> sjero.net Git - wget/commitdiff
[svn] Fix obvious memory leaks in the VMS directory parser.
authorhniksic <devnull@localhost>
Tue, 11 Dec 2001 05:29:52 +0000 (21:29 -0800)
committerhniksic <devnull@localhost>
Tue, 11 Dec 2001 05:29:52 +0000 (21:29 -0800)
Published in <sxsadwqpbo1.fsf@florida.arsdigita.de>.

src/ChangeLog
src/ftp-ls.c

index 6feff5c3bd9849d6289facc605d3e6505758d4a2..7c85fb594a8635f510d03af6ba463c704ae4f1b7 100644 (file)
@@ -1,3 +1,7 @@
+2001-12-11  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * ftp-ls.c (ftp_parse_vms_ls): Fix obvious memory leaks.
+
 2001-12-10  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * main.c (main): Initialize progress after fork_to_background, so
index 4279c4944a1463b4197b4709825c890f71f149c0..bf613b24938d4374aceca650afd9b06c93a0deaf 100644 (file)
@@ -577,23 +577,31 @@ ftp_parse_vms_ls (const char *file)
     }
   dir = l = NULL;
 
-  /* #### The next three lines are a memory leak because they don't
-     bother to free the pointer that read_whole_line() returns!
-     FIXME! */
+  /* Skip empty line. */
+  line = read_whole_line (fp);
+  if (line)
+    xfree (line);
 
-  /* Empty line */
-  read_whole_line (fp);
-  /* "Directory PUB$DEVICE[PUB]" */
-  read_whole_line (fp);
-  /* Empty line */
-  read_whole_line (fp);
+  /* 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
@@ -650,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, " ");
@@ -669,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;
@@ -718,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" */