diff options
author | David Hill <dhill@cvs.openbsd.org> | 2006-03-20 20:11:03 +0000 |
---|---|---|
committer | David Hill <dhill@cvs.openbsd.org> | 2006-03-20 20:11:03 +0000 |
commit | fc46bdd7356d3a09a8af408835950cd361e21c1c (patch) | |
tree | 590e345ca9d582742e0d9f12195bef9ebdcba8ad | |
parent | f2bcf8b2e2f2264bc32cdafdb7bff570972631dd (diff) |
NetBSD Coverity CID 2302: Free fat if fatal error to avoid leak.
ok otto@ deraadt@
-rw-r--r-- | sbin/fsck_msdos/fat.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sbin/fsck_msdos/fat.c b/sbin/fsck_msdos/fat.c index e3dbeaf7e89..637624b8f9a 100644 --- a/sbin/fsck_msdos/fat.c +++ b/sbin/fsck_msdos/fat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fat.c,v 1.12 2004/07/17 02:14:33 deraadt Exp $ */ +/* $OpenBSD: fat.c,v 1.13 2006/03/20 20:11:02 dhill Exp $ */ /* $NetBSD: fat.c,v 1.8 1997/10/17 11:19:53 ws Exp $ */ /* @@ -35,7 +35,7 @@ #ifndef lint -static char rcsid[] = "$OpenBSD: fat.c,v 1.12 2004/07/17 02:14:33 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: fat.c,v 1.13 2006/03/20 20:11:02 dhill Exp $"; #endif /* not lint */ #include <stdlib.h> @@ -191,7 +191,11 @@ readfat(int fs, struct bootblock *boot, int no, struct fatEntry **fp) } free(buffer); - *fp = fat; + if (ret & FSFATAL) { + free(fat); + *fp = NULL; + } else + *fp = fat; return (ret); } |