=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mg/fileio.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- src/usr.bin/mg/fileio.c 2002/08/22 23:28:19 1.34 +++ src/usr.bin/mg/fileio.c 2003/05/06 10:45:07 1.35 @@ -1,4 +1,4 @@ -/* $OpenBSD: fileio.c,v 1.34 2002/08/22 23:28:19 deraadt Exp $ */ +/* $OpenBSD: fileio.c,v 1.35 2003/05/06 10:45:07 vincent Exp $ */ /* * POSIX fileio.c @@ -168,14 +168,15 @@ char buf[BUFSIZ]; char *nname; + if (stat(fn, &sb) == -1) { + ewprintf("Can't stat %s : %s", fn, strerror(errno)); + return (FALSE); + } + if (asprintf(&nname, "%s~", fn) == -1) { ewprintf("Can't allocate temp file name : %s", strerror(errno)); return (ABORT); - } - if (stat(fn, &sb) == -1) { - ewprintf("Can't stat %s : %s", fn, strerror(errno)); - return (FALSE); } if ((from = open(fn, O_RDONLY)) == -1) {