Re: lftp produces segmentation fault with mirror --log command (Debian BTS#551062)

"Alexander V. Lukyanov" <[email protected]> Tue, 17 Aug 2010 09:40:43 +0400
Newsgroups gmane.network.lftp.devel
Message-ID <[email protected]>
--BOKacYhQ+x31HxR3
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by univ.uniyar.ac.ru id o7H5eq6B019398

On Sat, Jul 31, 2010 at 09:16:31PM +0200, No=EBl K=F6the wrote:
> lftp produces segmentation fault with mirror --log <logfile> command
> when logfile is under a folder which not exists.

This patch should fix it.

BTW, thanks for the postcard!

--=20
   Alexander.

--BOKacYhQ+x31HxR3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: MirrorJob.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/MirrorJob.cc,v
retrieving revision 1.171
diff -u -p -r1.171 MirrorJob.cc
--- MirrorJob.cc	21 Dec 2009 16:31:53 -0000	1.171
+++ MirrorJob.cc	17 Aug 2010 05:39:15 -0000
@@ -1275,6 +1275,8 @@ char *MirrorJob::SetScriptFile(const cha
    if(strcmp(n,"-"))
    {
       script=fopen(n,"w");
+      if(!script)
+	 return xasprintf("%s: %s",n,strerror(errno));
       setvbuf(script,NULL,_IOLBF,0);
       script_needs_closing=true;
    }
@@ -1283,9 +1285,7 @@ char *MirrorJob::SetScriptFile(const cha
       script=stdout;
       script_needs_closing=false;
    }
-   if(script)
-      return 0;
-   return xasprintf("%s: %s",n,strerror(errno));
+   return 0;
 }
 
 void MirrorJob::SetOnChange(const char *oc)
@@ -1696,6 +1696,7 @@ CMD(mirror)
       if(err)
       {
 	 eprintf("%s: %s\n",args->a0(),err.get());
+	 j->DeleteLater();
 	 return 0;
       }
    }

--BOKacYhQ+x31HxR3--