mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
fix a small memleak on errors. noticed by pat latifi.
ok millert, fgsch
This commit is contained in:
parent
d03cdbee8a
commit
ae6d376e73
@ -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,15 +168,16 @@ fbackupfile(const char *fn)
|
||||
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) {
|
||||
free(nname);
|
||||
|
Loading…
Reference in New Issue
Block a user