]> 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:31:24 +0000 (17:31 +0200)
src/main/radconf2xml.c

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