On Sat, Jul 31, 2010 at 09:16:31PM +0200, Noël Köthe 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!
--
Alexander.
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;
}
}