]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Don't delete a file twice if -i is given on the command line
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 9 Feb 2011 20:46:37 +0000 (20:46 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 9 Feb 2011 20:46:37 +0000 (20:46 +0000)
If sarg is ran with command line option -i, in some circunstances I have
yet to clarify, the ip file is not produced. In that case, the name of
the previously created file (whose name is still in the string buffer)
is deleted a second time. The result is a failure as the file doesn't
exists any more.

Thanks to Arnaud Florent for reporting this bug.

html.c

diff --git a/html.c b/html.c
index 74dd443403394ee380aa107243c6ca0f0d01170d..5d62d766fc88531894d4170d16b53823fde3c0d3 100644 (file)
--- a/html.c
+++ b/html.c
@@ -235,6 +235,7 @@ void htmlrel(void)
                        debuga(_("Making report: %s\n"),uinfo->id);
                }
                count=0;
+               arqip[0]='\0';
 
                while((buf=longline_read(fp_in,line))!=NULL) {
                        getword_start(&gwarea,buf);
@@ -498,7 +499,7 @@ void htmlrel(void)
                fclose(fp_in);
                longline_destroy(&line);
 
-               if (iprel) {
+               if (iprel && arqip[0]) {
                        if (unlink(arqip)) {
                                debuga(_("Cannot delete %s - %s\n"),arqip,strerror(errno));
                                exit(EXIT_FAILURE);