summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2009-12-10 16:01:52 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2009-12-10 16:01:52 +0000
commitaeaa0d96b61c1486b55caa3f67166deaadd1e1a4 (patch)
treec80173fa13ff53916c0ba3f5341af25c6ab1cf59
parentba451d4d33bde0a4f9ae8e07b0c3fecc3a7f92b2 (diff)
do not leak memory, found by parfait, ok millert otto
(one case was a false positive, but one is a modified copy of the other)
-rw-r--r--sbin/fsck_ext2fs/utilities.c4
-rw-r--r--sbin/fsck_ffs/utilities.c9
2 files changed, 7 insertions, 6 deletions
diff --git a/sbin/fsck_ext2fs/utilities.c b/sbin/fsck_ext2fs/utilities.c
index 8eeb75c8050..1e5c735fd52 100644
--- a/sbin/fsck_ext2fs/utilities.c
+++ b/sbin/fsck_ext2fs/utilities.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utilities.c,v 1.17 2006/04/20 02:24:38 deraadt Exp $ */
+/* $OpenBSD: utilities.c,v 1.18 2009/12/10 16:01:50 deraadt Exp $ */
/* $NetBSD: utilities.c,v 1.6 2001/02/04 21:19:34 christos Exp $ */
/*
@@ -129,6 +129,8 @@ bufinit(void)
bp = (struct bufarea *)malloc(sizeof(struct bufarea));
bufp = malloc((unsigned int)sblock.e2fs_bsize);
if (bp == NULL || bufp == NULL) {
+ free(bp);
+ free(bufp);
if (i >= MINBUFS)
break;
errexit("cannot allocate buffer pool\n");
diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c
index 43866d42bfd..e4a33b184ad 100644
--- a/sbin/fsck_ffs/utilities.c
+++ b/sbin/fsck_ffs/utilities.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utilities.c,v 1.36 2009/10/27 23:59:32 deraadt Exp $ */
+/* $OpenBSD: utilities.c,v 1.37 2009/12/10 16:01:51 deraadt Exp $ */
/* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */
/*
@@ -139,11 +139,10 @@ bufinit(void)
bp = malloc(sizeof(struct bufarea));
bufp = malloc((unsigned int)sblock.fs_bsize);
if (bp == NULL || bufp == NULL) {
- if (i >= MINBUFS) {
- free(bp);
- free(bufp);
+ free(bp);
+ free(bufp);
+ if (i >= MINBUFS)
break;
- }
errexit("cannot allocate buffer pool\n");
}
bp->b_un.b_buf = bufp;