diff options
author | 2006-03-20 20:11:02 +0000 | |
---|---|---|
committer | 2006-03-20 20:11:02 +0000 | |
commit | 49b519dc9628122b35d1376ef45ddbf7ebc3d362 (patch) | |
tree | 09e9b1836d3ee75baa579a8bcfa245d60dc4bcbc /sbin/fsck_msdos | |
parent | NetBSD Coverity CID 774: Don't increment a pointer *before* testing it for NULL! (diff) | |
download | wireguard-openbsd-49b519dc9628122b35d1376ef45ddbf7ebc3d362.tar.xz wireguard-openbsd-49b519dc9628122b35d1376ef45ddbf7ebc3d362.zip |
NetBSD Coverity CID 2302: Free fat if fatal error to avoid leak.
ok otto@ deraadt@
Diffstat (limited to 'sbin/fsck_msdos')
-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); } |