summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hill <dhill@cvs.openbsd.org>2006-03-20 21:35:38 +0000
committerDavid Hill <dhill@cvs.openbsd.org>2006-03-20 21:35:38 +0000
commite90c15add55da0960507e2dc56f61b16e6875992 (patch)
tree07f0ca64cc9d2a1f2247c4c749e2e54e154b70e1
parent00a4bc74a026e5f7ccb2d2ea5e371da484aa4a06 (diff)
NetBSD Coverity CID 2298: Fix memory leak.
NetBSD Coverity CID 2299: Fix memory leak. NetBSD Coverity CID 2301: Fix memory leak. ok ray@
-rw-r--r--sbin/fsck_ext2fs/dir.c17
-rw-r--r--sbin/fsck_ext2fs/pass5.c4
2 files changed, 13 insertions, 8 deletions
diff --git a/sbin/fsck_ext2fs/dir.c b/sbin/fsck_ext2fs/dir.c
index d6790e5dfdf..1550ce7275d 100644
--- a/sbin/fsck_ext2fs/dir.c
+++ b/sbin/fsck_ext2fs/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.13 2005/04/30 13:56:15 niallo Exp $ */
+/* $OpenBSD: dir.c,v 1.14 2006/03/20 21:35:37 dhill Exp $ */
/* $NetBSD: dir.c,v 1.5 2000/01/28 16:01:46 bouyer Exp $ */
/*
@@ -126,6 +126,7 @@ dirscan(struct inodesc *idesc)
blksiz = idesc->id_numfrags * sblock.e2fs_bsize;
if (chkrange(idesc->id_blkno, idesc->id_numfrags)) {
idesc->id_filesize -= blksiz;
+ free(dbuf);
return (SKIP);
}
idesc->id_loc = 0;
@@ -514,11 +515,6 @@ expanddir(struct ext2fs_dinode *dp, char *name)
struct bufarea *bp;
char *firstblk;
- if ((firstblk = malloc(sblock.e2fs_bsize)) == NULL) {
- fprintf(stderr, "out of memory");
- exit(8);
- }
-
lastbn = lblkno(&sblock, inosize(dp));
if (lastbn >= NDADDR - 1 || fs2h32(dp->e2di_blocks[lastbn]) == 0 ||
inosize(dp) == 0)
@@ -533,11 +529,18 @@ expanddir(struct ext2fs_dinode *dp, char *name)
sblock.e2fs_bsize);
if (bp->b_errs)
goto bad;
+ if ((firstblk = malloc(sblock.e2fs_bsize)) == NULL) {
+ fprintf(stderr, "out of memory\n");
+ exit(8);
+ }
memcpy(firstblk, bp->b_un.b_buf, sblock.e2fs_bsize);
bp = getdirblk(newblk, sblock.e2fs_bsize);
- if (bp->b_errs)
+ if (bp->b_errs) {
+ free(firstblk);
goto bad;
+ }
memcpy(bp->b_un.b_buf, firstblk, sblock.e2fs_bsize);
+ free(firstblk);
dirty(bp);
bp = getdirblk(fs2h32(dp->e2di_blocks[lastbn + 1]),
sblock.e2fs_bsize);
diff --git a/sbin/fsck_ext2fs/pass5.c b/sbin/fsck_ext2fs/pass5.c
index 3ae4e2ae552..a08e408ba6f 100644
--- a/sbin/fsck_ext2fs/pass5.c
+++ b/sbin/fsck_ext2fs/pass5.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass5.c,v 1.12 2003/06/11 06:22:13 deraadt Exp $ */
+/* $OpenBSD: pass5.c,v 1.13 2006/03/20 21:35:37 dhill Exp $ */
/* $NetBSD: pass5.c,v 1.7 2000/01/28 16:01:46 bouyer Exp $ */
/*
@@ -227,6 +227,8 @@ pass5(void)
fs->e2fs.e2fs_ficount = cs_nifree;
sbdirty();
}
+ free(ibmap);
+ free(bbmap);
}
void