From 3f6913663e4987f12fd489b081d3d8b28d9652b6 Mon Sep 17 00:00:00 2001
From: hniksic <devnull@localhost>
Date: Tue, 14 Oct 2003 15:52:12 -0700
Subject: [PATCH] [svn] Correctly loop through the linked list. By Philip
 Stadermann.

---
 src/ChangeLog | 5 +++++
 src/ftp.c     | 9 ++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 1dcca90e..1c94f771 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-15  Philip Stadermann  <philip.stadermann@credativ.de>
+
+	* ftp.c (ftp_retrieve_glob): Correctly loop through the list whose
+	elements might have been deleted.
+
 2003-10-13  Hrvoje Niksic  <hniksic@xemacs.org>
 
 	* html-url.c (tag_handle_meta): Set the Refresh link to expect
diff --git a/src/ftp.c b/src/ftp.c
index 5a84a9d8..7e997393 100644
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -1618,20 +1618,19 @@ has_insecure_name_p (const char *s)
 static uerr_t
 ftp_retrieve_glob (struct url *u, ccon *con, int action)
 {
-  struct fileinfo *f, *orig, *start;
+  struct fileinfo *f, *start;
   uerr_t res;
 
   con->cmd |= LEAVE_PENDING;
 
-  res = ftp_get_listing (u, con, &orig);
+  res = ftp_get_listing (u, con, &start);
   if (res != RETROK)
     return res;
-  start = orig;
   /* First: weed out that do not conform the global rules given in
      opt.accepts and opt.rejects.  */
   if (opt.accepts || opt.rejects)
     {
-      f = orig;
+      f = start;
       while (f)
 	{
 	  if (f->type != FT_DIRECTORY && !acceptable (f->name))
@@ -1644,7 +1643,7 @@ ftp_retrieve_glob (struct url *u, ccon *con, int action)
 	}
     }
   /* Remove all files with possible harmful names */
-  f = orig;
+  f = start;
   while (f)
     {
       if (has_insecure_name_p (f->name))