diff options
-rw-r--r-- | imake.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -399,17 +399,16 @@ main(int argc, char *argv[]) if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL) LogFatal("Cannot create temporary file %s.", tmpMakefile); } else { -#ifdef HAVE_MKSTEMP - int fd; -#endif char *tmpMakefileName = Strdup(tmpMakefileTemplate); + #ifndef HAVE_MKSTEMP if (mktemp(tmpMakefileName) == NULL || (tmpfd = fopen(tmpMakefileName, "w+")) == NULL) { LogFatal("Cannot create temporary file %s.", tmpMakefileName); } #else - fd = mkstemp(tmpMakefileName); + int fd = mkstemp(tmpMakefileName); + if (fd == -1 || (tmpfd = fdopen(fd, "w+")) == NULL) { if (fd != -1) { unlink(tmpMakefileName); close(fd); |