]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Unlink file only if it exists
authorAlan T. DeKok <aland@freeradius.org>
Wed, 19 Oct 2011 15:05:25 +0000 (17:05 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 19 Oct 2011 15:05:25 +0000 (17:05 +0200)
src/main/radconf2xml.c

index 8b20255b15189038922732090532a21066c3abde..a3b00dcf4fa3c7d2f6edacd57719cb3b283194d3 100644 (file)
@@ -111,6 +111,7 @@ int main(int argc, char **argv)
 
        if (!file || (strcmp(file, "-") == 0)) {
                fp = stdout;
+               file = NULL;
        } else {
                fp = fopen(file, "w");
                if (!fp) {
@@ -121,7 +122,7 @@ int main(int argc, char **argv)
        }
 
        if (!cf_section2xml(fp, cs)) {
-               if (fp != stdout) unlink(file);
+               if (file) unlink(file);
                return 1;
        }